gt_merge_stack {gtExtras} | R Documentation |
Merge and stack text from two columns in gt
Description
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 |
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 |
... |
Arguments passed on to
|
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
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()