gt
and color one with school colorsR/gt_stack_team.R
gt_stack_team.Rd
The gt_merge_stack_team_color()
function takes an existing gt
table and merges
column 1 and column 2, stacking column 1's text on top of column 2's.
Top text is in all caps with black bold text, while the lower text is smaller
and colored by the team name in another column.
This is a slightly modified version of gtExtras::gt_merge_stack()
written by Tom Mock.
gt_merge_stack_team_color(
gt_object,
col1,
col2,
team_col,
font_size_top = 14,
font_size_bottom = 12,
color = "black"
)
An existing gt table object of class gt_tbl
The column to stack on top. Will be converted to all caps, with black and bold text.
The column to merge and place below. Will be smaller and the school color that corresponds to team_col
.
The column of team names that match valid_team_names()
for the color of the bottom.
the font size for the top text.
the font size for the bottom text.
The color for the top text.
An object of class gt_tbl
.
library(gt)
teams <- "https://github.com/sportsdataverse/cfbfastR-data/raw/master/team_info/rds/cfb_team_info_2020.rds"
team_df <- readRDS(url(teams))
#> Warning: cannot open URL 'https://github.com/sportsdataverse/cfbfastR-data/raw/master/team_info/rds/cfb_team_info_2020.rds': HTTP status was '404 Not Found'
#> Error in readRDS(url(teams)): cannot open the connection to 'https://github.com/sportsdataverse/cfbfastR-data/raw/master/team_info/rds/cfb_team_info_2020.rds'
stacked_tab <- team_df %>%
transmute(logo = school,school,mascot,conference,city,state) %>%
head(8) %>%
gt::gt() %>%
gt_merge_stack_team_color(school,mascot,school) %>%
cfbplotR::gt_fmt_cfb_logo(columns = c("logo","conference"))
#> Error in transmute(., logo = school, school, mascot, conference, city, state): object 'team_df' not found