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.
Usage
gt_merge_stack_team_color(
gt_object,
col1,
col2,
team_col,
league,
font_size_top = 14,
font_size_bottom = 12,
color = "black",
background = NULL,
season = NULL,
id_system = "auto"
)Arguments
- gt_object
An existing gt table object of class
gt_tbl.- col1
The column to stack on top. Will be all caps, black bold text.
- col2
The column to merge and place below. Will be smaller and colored.
- team_col
The column of team names for the color of the bottom text.
- league
A league key from
sdv_leagues().- font_size_top
Font size for the top text.
- font_size_bottom
Font size for the bottom text.
- color
The color for the top text.
- background
The cell background the lower text is checked against.
NULL(the default) reads the table's background color, so a table theme such asgt_theme_midnight()applied before this function is taken into account; a theme applied afterwards isn't seen, so setbackgroundthen. A table with no background color set counts as white.- season
NULLfor today's mark, or a season (or one per team): the mark the team wore that season where the archive dates its marks.- id_system
"auto"(try every id system in priority order) or one id system:"team_id","espn","espn_abbr","nhl","nflverse","mlbstats","nba_api","hockeytech","ncaa","pff","cricinfo","cfbd","bref","sportsipy","fangraphs","yahoo","kenpom","torvik","sdvplotr","name", or one"auto"never tries because its numbers overlap ESPN's:"nhl_id"(NHL stats API ids),"fox","cbs","sports247"(247Sports team and institution ids) or"on3".
Details
The lower text takes the team's primary color when it clears a 4.5:1 contrast ratio (WCAG AA) against the cell background, else the secondary color, else the primary darkened (or lightened, on a dark background) until it does, so a light primary such as Missouri's gold stays readable on a white table and keeps its gold on a dark one.
