Created
October 20, 2020 15:38
-
-
Save gallochris/eb03dbee702e860bb36aa43d1ae6b8f4 to your computer and use it in GitHub Desktop.
2019-20 Minutes played UNC
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(gt) | |
# make the data | |
injury <- tibble::tribble( | |
~Opp,~Anthony,~Keeling,~Robinson,~Black,~Brooks,~Bacot,~Pierce,~Platek,~Francis,~Harris,~Manley, | |
"Notre Dame",37,21,0,33,39,23,20,26,0,0,0, | |
"at UNC-Wilmington",34,23,0,32,33,3,32,27,0,0,0, | |
"Gardner-Webb",33,30,0,34,30,23,21,23,0,0,0, | |
"Elon",36,25,0,27,33,26,23,18,0,0,0, | |
"Alabama",32,14,26,34,37,26,16,15,0,0,0, | |
"Michigan",33,16,32,21,33,22,17,16,0,0,0, | |
"Oregon",28,22,31,9,32,31,16,18,0,0,0, | |
"Ohio State",30,9,31,25,28,7,23,12,0,0,0, | |
"at Virginia",35,15,26,22,33,25,17,11,3,6,0, | |
"Wofford",0,20,33,0,33,29,10,20,16,10,0, | |
"at Gonzaga",0,20,16,21,31,14,20,13,23,14,0, | |
"UCLA",0,8,33,22,36,32,10,4,28,17,0, | |
"Yale",0,9,36,29,35,17,28,0,27,13,0, | |
"Georgia Tech",0,17,34,28,36,16,24,0,27,0,0, | |
"Pitt",0,6,34,34,37,31,12,19,24,0,0, | |
"Clemson",0,10,41,41,37,37,16,39,0,0,0, | |
"at Pitt",0,16,32,34,38,29,16,18,15,0,0, | |
"at Virginia Tech",0,9,0,47,48,29,45,49,23,0,0, | |
"Miami",0,16,32,26,27,33,17,27,0,0,0, | |
"at NC State",0,24,29,29,38,27,14,27,0,0,0, | |
"Boston College",26,10,37,28,34,31,12,17,3,0,0, | |
"at Florida State",38,18,0,34,34,26,15,32,3,0,0, | |
"Duke",43,26,0,32,36,29,20,36,0,0,0, | |
"at Wake Forest",36,30,0,29,29,26,15,14,6,0,0, | |
"Virginia",35,33,0,33,36,34,10,19,0,0,0, | |
"at Notre Dame",38,27,25,34,36,24,10,4,0,0,0, | |
"at Louisville",33,25,30,34,0,33,0,17,6,0,0, | |
"NC State",37,27,20,31,37,13,28,6,0,0,0, | |
"at Syracuse",36,27,30,36,37,9,18,5,0,0,0, | |
"Wake Forest",38,27,35,32,35,0,24,7,0,0,0, | |
"at Duke",39,19,29,30,37,24,13,5,1,0,0, | |
"Virginia Tech",34,18,30,26,34,29,16,8,3,0,0, | |
"Syracuse",37,16,22,24,37,25,10,9,10,0,0 | |
) | |
gt_tbl <- gt(data = injury) | |
# set theme | |
gt_theme_538 <- function(data,...) { | |
data %>% | |
opt_all_caps() %>% | |
opt_table_font( | |
font = list( | |
google_font("Chivo"), | |
default_fonts() | |
) | |
) %>% | |
tab_style( | |
style = cell_borders( | |
sides = "bottom", color = "transparent", weight = px(2) | |
), | |
locations = cells_body( | |
columns = TRUE, | |
# This is a relatively sneaky way of changing the bottom border | |
# Regardless of data size | |
rows = nrow(data$`_data`) | |
) | |
) %>% | |
tab_options( | |
column_labels.background.color = "white", | |
table.border.top.width = px(3), | |
table.border.top.color = "transparent", | |
table.border.bottom.color = "transparent", | |
table.border.bottom.width = px(3), | |
column_labels.border.top.width = px(3), | |
column_labels.border.top.color = "transparent", | |
column_labels.border.bottom.width = px(3), | |
column_labels.border.bottom.color = "black", | |
data_row.padding = px(3), | |
source_notes.font.size = 12, | |
table.font.size = 16, | |
heading.align = "left", | |
... | |
) | |
} | |
# style the table | |
gt_tbl <- | |
gt_tbl %>% | |
data_color( | |
columns = vars(Anthony,Keeling,Robinson,Black,Brooks,Bacot,Pierce,Platek,Francis,Harris), | |
colors = scales::col_numeric( | |
palette = c("black", "#ddecf6", "#aacfe9", "#77b3db", "#56a0d3"), | |
domain = NULL | |
) | |
) %>% | |
data_color( | |
columns = vars(Manley), | |
colors = scales::col_numeric( | |
palette = c("black", "black"), | |
domain = NULL | |
) | |
) %>% | |
cols_label( | |
Opp = "Opponent" | |
) %>% | |
tab_header( | |
title = "Carolina: Game-by-Game Minutes by Player in 2019-20 Season", | |
subtitle = "11 scholarship players missed a combined 104 games. A black square indicates a game missed due to illness or injury." | |
) %>% | |
tab_source_note( | |
source_note = "Source: goheels.com and sports-reference.com" | |
) %>% | |
gt_theme_538() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment