-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculate-fantasy-points.R
89 lines (83 loc) · 2.22 KB
/
calculate-fantasy-points.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
library(tidyverse)
# Calculate pre-TI fantasy points
calculate_fantasy_points_pre <- function() {
fantasy_stats <- read.csv(
"data/fantasy_stats_pre.csv",
colClasses = c(
player_id = "character",
match_id = "character",
hero_id = "character"
)
)
fantasy_points <- fantasy_stats %>%
transmute(
player_id,
match_id,
hero_id,
win,
kills = kills*0.3,
deaths = 3 - deaths*0.3,
creep_score = creep_score*0.003,
gold_per_min = gold_per_min*0.002,
tower_kills,
roshan_kills,
team_fight = team_fight*3,
obs_wards_planted = obs_wards_planted*0.5,
camps_stacked = camps_stacked*0.5,
runes_grabbed = runes_grabbed*0.25,
first_blood = first_blood*4,
stuns = stuns*0.05,
total = kills + deaths + creep_score + gold_per_min + tower_kills +
roshan_kills + team_fight + obs_wards_planted + camps_stacked +
runes_grabbed + first_blood + stuns
)
write.csv(
fantasy_points,
"data/fantasy_points_pre.csv",
row.names = FALSE,
quote = TRUE
)
}
# Calculate TI fantasy points
calculate_fantasy_points_ti <- function() {
fantasy_stats <- read.csv(
"data/fantasy_stats_ti.csv",
colClasses = c(
player_id = "character",
match_id = "character",
hero_id = "character"
)
)
fantasy_points <- fantasy_stats %>%
transmute(
player_id,
match_id,
match_time,
match_duration,
series_id,
series_type,
hero_id,
win,
kills = kills*0.3,
deaths = 3 - deaths*0.3,
creep_score = creep_score*0.003,
gold_per_min = gold_per_min*0.002,
tower_kills,
roshan_kills,
team_fight = team_fight*3,
obs_wards_planted = obs_wards_planted*0.5,
camps_stacked = camps_stacked*0.5,
runes_grabbed = runes_grabbed*0.25,
first_blood = first_blood*4,
stuns = stuns*0.05,
total = kills + deaths + creep_score + gold_per_min + tower_kills +
roshan_kills + team_fight + obs_wards_planted + camps_stacked +
runes_grabbed + first_blood + stuns
)
write.csv(
fantasy_points,
"data/fantasy_points_ti.csv",
row.names = FALSE,
quote = TRUE
)
}