Skip to contents

The gt_merge_stack() 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 dark grey.

Usage

gt_merge_stack(
  gt_object,
  col1,
  col2,
  palette = c("black", "grey"),
  ...,
  small_cap = TRUE,
  font_size = c("14px", "10px"),
  font_weight = c("bold", "bold")
)

Arguments

gt_object

An existing gt table object of class gt_tbl

col1

The column to stack on top. Will be converted to all caps, with black and bold text.

col2

The column to merge and place below. Will be smaller and dark grey.

palette

The colors for the text, where the first color is the top , ie col1 and the second color is the bottom, ie col2. Defaults to c("black","grey"). For more information on built-in color names, see colors().

...

Arguments passed on to scales::col2hcl

h

Hue, [0, 360]

c

Chroma, [0, 100]

l

Luminance, [0, 100]

alpha

Alpha, [0, 1].

small_cap

a logical indicating whether to use 'small-cap' on the top line of text

font_size

a string of length 2 indicating the font-size in px of the top and bottom text

font_weight

a string of length 2 indicating the 'font-weight' of the top and bottom text. Must be one of 'bold', 'normal', 'lighter'

Value

An object of class gt_tbl.

Examples

library(gt)
teams <- "https://github.com/nflverse/nflfastR-data/raw/master/teams_colors_logos.rds"
team_df <- readRDS(url(teams))

stacked_tab <- team_df %>%
 dplyr::select(team_nick, team_abbr, team_conf, team_division, team_wordmark) %>%
 head(8) %>%
 gt(groupname_col = "team_conf") %>%
 gt_merge_stack(col1 = team_nick, col2 = team_division) %>%
 gt_img_rows(team_wordmark)

Figures

Function ID

2-6