-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
189 lines (175 loc) · 7.28 KB
/
index.Rmd
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
title: "Fantasy League of Ex-Athletes"
description: |
Welcome to our site for league history, blogs, and more
site: distill_website
author: "Joe Sydlowski"
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
library(ffscrapr)
library(tidyverse)
library(gt)
library(RColorBrewer)
library(emoji)
library(here)
library(glue)
setwd(here())
flea_df <- readRDS("data/flea_df_2024.RDS") %>%
rowwise() %>%
mutate(best_headshot = best_headshot[1],
worst_headshot = worst_headshot[1]) %>%
select(-years)
```
# Active Teams
```{r layout = "l-page"}
start_year <- 2015
end_year <- 2024
flea_df %>%
filter(user_name %in% c("Eric Bulak",
"Neal Galletti",
"Jonathan Sydlowski",
"Josh Noel",
"Lizandro Sanchez",
"Nick Duncan",
"Nick Galletti",
"Joe Sydlowski",
"Ryan Galletti",
"Chris Knafelc",
"Josh 'Steve' Gruenke",
"Scott Wilkens")) |>
gt() %>%
tab_header(title = "League History (2015-2024)") %>%
cols_label(user_name = "Team",
# years = "Seasons",
# pick_year = "Draft Slots",
emoji_collase = glue::glue("{start_year}\U2192{end_year}"),
allplay_winpct = "All-play Win %",
h2h_winpct = "Win %",
luck_pct = "Luck %",
team_logo_espn = "Top Drafted Team",
best_combo = "Best Pick",
best_headshot = "",
worst_combo = "Worst Pick",
worst_headshot = "",
injury_value_oe = "Lost to Injury",
draft_value_oe = "Over Expected") %>%
cols_move(columns = c(emoji_collase, allplay_winpct, h2h_winpct, luck_pct,
injury_value_oe, draft_value_oe,
best_combo, best_headshot, worst_combo, worst_headshot, team_logo_espn),
after = user_name) %>%
fmt_percent(columns = c(allplay_winpct, h2h_winpct, luck_pct, injury_value_oe, draft_value_oe),
decimals = 1) %>%
tab_spanner(label = "Draft Value",
columns = c(injury_value_oe, draft_value_oe)) %>%
text_transform(
locations = cells_body(columns = c(best_headshot, worst_headshot)),
fn = function(x){ gt::web_image(x, height = 45) }) %>%
text_transform(
locations = cells_body(columns = c(team_logo_espn)),
fn = function(x){ gt::web_image(x, height = 45) }) %>%
cols_align(align = "left",
columns = c(best_combo, worst_combo)) %>%
cols_align(align = "right",
columns = c(emoji_collase)) %>%
cols_align(align = "center",
columns = team_logo_espn) %>%
tab_style(style = cell_text(whitespace = "nowrap"),
locations = cells_body(columns = emoji_collase)) %>%
data_color(
columns = c(h2h_winpct, allplay_winpct, luck_pct, draft_value_oe),
fn = scales::col_factor(
brewer.pal(11,'PRGn')[3:8],
domain = NULL
)) %>%
data_color(
columns = c(injury_value_oe),
fn = scales::col_factor(
brewer.pal(11,'PRGn')[8:3],
domain = NULL
)) %>%
cols_width(
contains("headshot") ~ px(55),
team_logo_espn ~ px(55),
emoji_collase ~ px(150)
) %>%
tab_footnote(footnote = "What would your win rate be if you played every team each week?",
locations = cells_column_labels(columns = allplay_winpct)) %>%
tab_footnote(footnote = "Difference between your win rate and all play win rate",
locations = cells_column_labels(columns = luck_pct)) %>%
tab_footnote(footnote = "Percent of your draft capital lost to injuries",
locations = cells_column_labels(columns = injury_value_oe)) %>%
tab_footnote(footnote = "Value returned on each draft pick",
locations = cells_column_labels(columns = draft_value_oe)) %>%
tab_source_note(source_note = emoji_glue(":trophy: Best Team, :2nd_place_medal: 2nd Place, :3rd_place_medal: 3rd Place, :flexed_biceps: Playoffs, :wastebasket: Missed Playoffs, :taco: Worst Team, :black_square_button: Didn't Play"))
```
# Full History
```{r layout = "l-page"}
start_year <- 2015
end_year <- 2024
flea_df %>%
gt() %>%
tab_header(title = "League History (2015-2024)") %>%
cols_label(user_name = "Team",
# years = "Seasons",
# pick_year = "Draft Slots",
emoji_collase = glue::glue("{start_year}\U2192{end_year}"),
allplay_winpct = "All-play Win %",
h2h_winpct = "Win %",
luck_pct = "Luck %",
team_logo_espn = "Top Drafted Team",
best_combo = "Best Pick",
best_headshot = "",
worst_combo = "Worst Pick",
worst_headshot = "",
injury_value_oe = "Lost to Injury",
draft_value_oe = "Over Expected") %>%
cols_move(columns = c(emoji_collase, allplay_winpct, h2h_winpct, luck_pct,
injury_value_oe, draft_value_oe,
best_combo, best_headshot, worst_combo, worst_headshot, team_logo_espn),
after = user_name) %>%
fmt_percent(columns = c(allplay_winpct, h2h_winpct, luck_pct, injury_value_oe, draft_value_oe),
decimals = 1) %>%
tab_spanner(label = "Draft Value",
columns = c(injury_value_oe, draft_value_oe)) %>%
text_transform(
locations = cells_body(columns = c(best_headshot, worst_headshot)),
fn = function(x){ gt::web_image(x, height = 45) }) %>%
text_transform(
locations = cells_body(columns = c(team_logo_espn)),
fn = function(x){ gt::web_image(x, height = 45) }) %>%
cols_align(align = "left",
columns = c(best_combo, worst_combo)) %>%
cols_align(align = "right",
columns = c(emoji_collase)) %>%
cols_align(align = "center",
columns = team_logo_espn) %>%
tab_style(style = cell_text(whitespace = "nowrap"),
locations = cells_body(columns = emoji_collase)) %>%
data_color(
columns = c(h2h_winpct, allplay_winpct, luck_pct, draft_value_oe),
fn = scales::col_factor(
brewer.pal(11,'PRGn')[3:8],
domain = NULL
)) %>%
data_color(
columns = c(injury_value_oe),
fn = scales::col_factor(
brewer.pal(11,'PRGn')[8:3],
domain = NULL
)) %>%
cols_width(
contains("headshot") ~ px(55),
team_logo_espn ~ px(55),
emoji_collase ~ px(150)
) %>%
tab_footnote(footnote = "What would your win rate be if you played every team each week?",
locations = cells_column_labels(columns = allplay_winpct)) %>%
tab_footnote(footnote = "Difference between your win rate and all play win rate",
locations = cells_column_labels(columns = luck_pct)) %>%
tab_footnote(footnote = "Percent of your draft capital lost to injuries",
locations = cells_column_labels(columns = injury_value_oe)) %>%
tab_footnote(footnote = "Value returned on each draft pick",
locations = cells_column_labels(columns = draft_value_oe)) %>%
tab_source_note(source_note = emoji_glue(":trophy: Best Team, :2nd_place_medal: 2nd Place, :3rd_place_medal: 3rd Place, :flexed_biceps: Playoffs, :wastebasket: Missed Playoffs, :taco: Worst Team, :black_square_button: Didn't Play"))
```