gt_merge_stack_team_color | R Documentation |
gt
and color one with team colorsThe 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 while the lower text is bigger, bolded,
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_sizes = c(12, 14),
font_weights = c("lighter", "bold"),
font_variants = c("small-caps"),
color = "black"
)
gt_object |
An existing gt table object of class |
col1 |
The column to stack on top. |
col2 |
The column to merge and place below with the text team color that corresponds to |
team_col |
The column of team abbreviations (cleaned with |
font_sizes |
the font size for the top and bottom text in px. Can be vector of length 1 or 2. Defaults to c(12, 14) |
font_weights |
the font weight of the top and bottom text. Can be vector of length 1 or 2. Defaults to c("lighter", "bold") |
font_variants |
the font variant of the top and bottom text. Can be vector of length 1 or 2. Defaults to "small-caps" |
color |
The color for the top text. |
An object of class gt_tbl
.
library(gt)
library(mlbplotR)
gt_merge_example <- mlbplotR::load_mlb_teams() %>%
dplyr::slice(1:5) %>%
dplyr::select(team_abbr, team_location, team_mascot) %>%
gt::gt() %>%
gt_merge_stack_team_color(col1 = "team_location",
col2 = "team_mascot",
team_col = "team_abbr")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.