-
Notifications
You must be signed in to change notification settings - Fork 0
/
draft_order_code.R
126 lines (105 loc) · 3.54 KB
/
draft_order_code.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
managers <- tibble(
name = c("Chad", "Jeff", "Tyson", "Oleary", "Clayton", "Darrin", "Wasyl", "Kelsey"),
logo = c("cozens_eddie", "relitz_relish", "dernic_dynasty", "craigs_button", "mikado_magic", "campbells_soup", "double_dions", "yorkton_g_spots")
)
draft_order <- tibble(
round = rep(1:6, each = 8),
pick = rep(seq(1:8), times = 6),
selections = drafted_players,
owner = c(managers$name, rev(managers$name), managers$name, rev(managers$name), managers$name, rev(managers$name))
) %>%
inner_join(managers, by = c("owner" = "name")) %>%
mutate(team = to_upper_camel_case(logo, sep_in = "_", sep_out = " "),
team = str_replace_all(team, "Yorkton G Spots", "Yorkton G-Spots")) %>%
relocate(team, .before = selections) %>%
inner_join(national_rosters[,c(1,4,6)], by = c("selections" = "player")) %>%
relocate(position, .after = selections) %>%
mutate(pos_fac = case_when(position == "F" ~ "1",
position == "D" ~ "2",
position == "G" ~ "3",
TRUE ~ position),
pos_fac = as.numeric(pos_fac)) %>%
rownames_to_column(var = "overall") %>%
write_csv("draft.csv")
drafted_players <- c(
"Dawson Mercer",
"Quinton Byfield",
"Dylan Cozens",
"Trevor Zegras",
"Cole Caufield",
"Tim Stutzle",
"Yaroslav Askarov",
"Dylan Holloway",
"Spencer Knight",
"Connor McMichael",
"Lucas Raymond",
"Hugo Alnefelt",
"Marco Rossi",
"Matthew Beniers",
"Philip Broberg",
"Cam York",
"Alexander Holtz",
"Aku Raty",
"Anton Lundell",
"Jamie Drysdale",
"Alex Newhook",
"Vasily Podkolzin",
"Alex Turcotte",
"Shakir Mukhamadullin",
"Arvid Costmar",
"Tobias Bjornfot",
"Taylor Gauthier",
"Rodion Amirov",
"Lukas Parik",
"Victor Soderstrom",
"Samuel Hlavaj",
"Mikhail Abramov",
"Joel Blomqvist",
"Simon Knak",
"Arno Tiefensee",
"Egor Afanasyev",
"Ville Heinola",
"Jake Sanderson",
"Roni Hirvonen",
"Henri Nikkanen",
"Jack Quinn",
"Peyton Krebs",
"Bobby Brink",
"Arthur Kaliyev",
"Cole Perfetti",
"Bowen Byram",
"Matthew Boldy",
"Connor Zary"
)
home <- schedule %>%
filter(phase == "Round Robin") %>%
select(date, "nation" = home_team)
away <- schedule %>%
filter(phase == "Round Robin") %>%
select(date, "nation" = away_team)
schedule_long <- bind_rows(home, away) %>%
mutate(
nation = str_replace_all(nation, "SUI", "switzerland"),
nation = str_replace_all(nation, "GER", "germany"),
nation = str_replace_all(nation, "RUS", "russia"),
nation = str_replace_all(nation, "FIN", "finland"),
nation = str_replace_all(nation, "AUT", "austria"),
nation = str_replace_all(nation, "CZE", "czech_republic"),
nation = str_replace_all(nation, "CAN", "canada"),
nation = str_replace_all(nation, "SVK", "slovakia"),
nation = str_replace_all(nation, "SWE", "sweden"),
nation = str_replace_all(nation, "USA", "usa"),
date = as.Date(date)
)
playing_today <- inner_join(schedule_long, draft_order[, c(5, 4, 9)], by = c("nation")) %>%
write_csv("playing_today.csv")
rsconnect::setAccountInfo(name=Sys.getenv("rsconnect_name"),
token=Sys.getenv("rsconnect_token"),
secret=Sys.getenv("rsconnect_secret"
)
library(rsconnect)
rsconnect::deployApp('~wjr_app/app.R')
schedule <- schedule %>%
mutate(home_team = str_replace_all(home_team, "USA", "US"),
away_team = str_replace_all(away_team, "USA", "US")) %>%
write_csv("schedule.csv")