gt_badge: Add a 'badge' based on values and palette

View source: R/html-helpers.R

gt_badgeR Documentation

Add a 'badge' based on values and palette

Description

Add a 'badge' based on values and palette

Usage

gt_badge(gt_object, column, palette = NULL, alpha = 0.2)

Arguments

gt_object

An existing gt table object

column

The column to convert to badges, accepts tidyeval

palette

Name of palette as a string. Must be either length of 1 or a vector of valid color names/hex values of equal length to the unique levels of the column (ie if there are 4 names, there need to be 4x colors). Note that if you would like to specify a specific color to match a specific icon, you can also use a named vector like: c("angle-double-up" = "#009E73", "angle-double-down" = "#D55E00","sort" = "#000000")

alpha

A numeric indicating the alpha/transparency. Range from 0 to 1

Value

gt table

Examples

library(gt)
head(mtcars) %>%
  dplyr::mutate(cyl = paste(cyl, "Cyl")) %>%
  gt() %>%
  gt_badge(cyl, palette = c("4 Cyl"="red","6 Cyl"="blue","8 Cyl"="green"))

Figures

gt_badge.png

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_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(), tab_style_by_grp()


gtExtras documentation built on Sept. 16, 2023, 1:08 a.m.