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.
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, iecol2
. Defaults toc("black","grey")
. For more information on built-in color names, seecolors()
.- ...
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'
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)
See also
Other Utilities:
add_text_img()
,
fa_icon_repeat()
,
fmt_pad_num()
,
fmt_pct_extra()
,
fmt_symbol_first()
,
generate_df()
,
gt_add_divider()
,
gt_badge()
,
gt_double_table()
,
gt_duplicate_column()
,
gt_fa_column()
,
gt_fa_rank_change()
,
gt_fa_rating()
,
gt_fa_repeats()
,
gt_highlight_cols()
,
gt_highlight_rows()
,
gt_img_border()
,
gt_img_circle()
,
gt_img_multi_rows()
,
gt_img_rows()
,
gt_index()
,
gt_merge_stack_color()
,
gt_two_column_layout()
,
gtsave_extra()
,
img_header()
,
pad_fn()
,
tab_style_by_grp()