Worst of the Worst: The Ten Worst Fantasy Football Outings of All Time
Load in the required libraries
library(reactable)
library(reactablefmtr)
library(tidyverse)
library(htmltools)
library(htmlwidgets)
Load in and begin to wrangle the data
ffp_wurst <- read.csv('/Users/trev/Desktop/Data Projects/R Files/all_time_ffp.csv')
ffp_wurst <- ffp_wurst %>%
mutate(headshot_url = coalesce(headshot_url, 'https://static.www.nfl.com/image/private/f_auto,q_auto/league/mdrlzgankwwjldxllgcx')) %>%
mutate(ffp = round(ffp, digits = 2)) %>%
mutate(rank = dense_rank(ffp)) %>%
filter(pos != 'P', pos != 'K') %>%
slice_min(ffp, n = 10, with_ties = FALSE) %>%
select(rank, headshot_url, player, team, pos, season, week, ffp:int)
Edit team names and clean variable names
ffp_wurst$team <- gsub('BUF', 'Buffalo Bills',
gsub('ARI', 'Arizona Cardinals',
gsub('NYJ', 'New York Jets',
gsub('DEN', 'Denver Broncos',
gsub('NYG', 'New York Giants',
gsub('TEN', 'Tennesee Titans',
gsub('HOU', 'Houston Texans',
ffp_wurst$team)))))))
ffp_wurst <- ffp_wurst %>%
mutate(pos_team = paste(pos, team, sep = ' | ')) %>%
select(rank, headshot_url, player, pos_team, season:int)
Assign color variables for table styling
back_blk = '#1A1A19'
text_white = '#F5F5EB'
button_red = '#FC6A55'
border = '#A8A89D'
Create reactable table
wurst_table <- ffp_wurst %>% reactable(data = .,
highlight = TRUE,
striped = FALSE,
borderless = FALSE,
fullWidth = FALSE,
pagination = FALSE,
theme = reactableTheme(
color = back_blk,
backgroundColor = text_white,
borderColor = border,
borderWidth = '2px',
cellPadding = '8px 12px'),
defaultColDef = colDef(align = 'center', vAlign = 'center', style = list(fontSize =18)),
style = list(fontFamily = 'urbanist'),
columnGroups = list(
colGroup(name = 'PASSING', columns = c('pass_yds', 'pass_tds', 'int')),
colGroup(name = 'RUSHING', columns = c('rush_yds', 'rush_tds', 'fumbles'))),
columns = list(
rank = colDef(name = '',
minWidth = 65,
style = list(fontFamily = 'Fjalla One', fontSize = 28)),
headshot_url = colDef(name = '',
minWidth = 110,
align = 'center',
cell = embed_img(height = 75, width = 105)),
player = colDef(name = 'PLAYER',
style = list(fontFamily = 'Fjalla One', fontSize = 24),
align = 'center',
minWidth = 200,
cell = merge_column(., 'pos_team', 'below', size = 20, merged_size = 14)),
pos_team = colDef(show = FALSE),
season = colDef(name = 'GAME',
minWidth = 105,
cell = merge_column(., "week", "right")),
week = colDef(show = FALSE),
ffp = colDef(name = 'POINTS',
cell = pill_buttons(., colors = button_red, bold_text = TRUE),
style = list(borderLeft = '2px solid #A8A89D', borderRight = '2px solid #A8A89D')),
pass_yds = colDef(name = 'YDS',
width = 72),
pass_tds = colDef(name = 'TDS',
width = 72),
int = colDef(name = 'INT',
width = 72,
style = list(borderRight = '2px solid #A8A89D')),
rush_yds = colDef(name = 'YDS',
width = 72),
rush_tds = colDef(name = 'TDS',
width = 72),
fumbles = colDef(name = 'FUM',
width = 72),
rec = colDef(show = FALSE),
rec_yds = colDef(show = FALSE),
rec_tds = colDef(show = FALSE),
twopoints = colDef(show = FALSE)))
#wurst_table
Add title and subtile to the table
wurst_table_final <- wurst_table %>%
htmlwidgets::prependContent(
tagList(
tags$div('Worst of the Worst', style = 'font-size:48px;
font-weight:bold;
font-family:Fjalla One;
color:#1A1A19;
margin-bottom:0;
display:inline-block;
vertical-align:middle;'),
tags$h3('The ten worst fantasy football performances since 2012 (ESPN standard PPR scoring)',style="font-family:urbanist;
font-size:18px;
margin-bottom:0;
margin-top:0;
font-weight:400;
color:#A8A89D;
padding-left:0px;")))
#wurst_table_final
Save the table as an HTML widget
saveWidget(wurst_table_final, '/Users/trev/Desktop/Data Projects/R Files/wurst_table_final.html', background = text_white)