| tab_style_by_grp {gtExtras} | R Documentation |
Add table styling to specific rows by group
Description
The tab_style_by_grp function takes an existing gt_tbl object and
styling according to each group. Currently it support styling the max()/min()
for each group.
Usage
tab_style_by_grp(gt_object, column, fn, ...)
Arguments
gt_object |
An existing gt table object of class |
column |
The column using tidy variable name or a number indicating which column should have the styling affect it. |
fn |
The name of a summarizing function (ie |
... |
Arguments passed to |
Value
An object of class gt_tbl.
Examples
library(gt)
df_in <- mtcars %>%
dplyr::select(cyl:hp, mpg) %>%
tibble::rownames_to_column() %>%
dplyr::group_by(cyl) %>%
dplyr::slice(1:4) %>%
dplyr::ungroup()
test_tab <- df_in %>%
gt(groupname_col = "cyl") %>%
tab_style_by_grp(mpg, fn = max,
cell_fill(color = "red", alpha = 0.5))
Figures
Function ID
2-12
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_merge_stack(),
gt_two_column_layout(),
gtsave_extra(),
img_header(),
pad_fn()