gt_fa_rank_change: Add rank change indicators to a gt table

View source: R/fontawesome-icons.R

gt_fa_rank_changeR Documentation

Add rank change indicators to a gt table

Description

Takes an existing gt table and converts a column of integers into various types of up/down arrows. Note that you need to specify a palette of three colors, in the order of up, neutral, down. Defaults to green, grey, purple. There are 6 supported fa_type, representing various arrows. Note that you can use font_color = 'match' to match the palette across arrows and text. show_text = FALSE will remove the text from the column, resulting only in colored arrows.

Usage

gt_fa_rank_change(
  gt_object,
  column,
  palette = c("#1b7837", "lightgrey", "#762a83"),
  fa_type = c("angles", "arrow", "turn", "chevron", "caret"),
  font_color = "black",
  show_text = TRUE
)

Arguments

gt_object

An existing gt table object

column

The single column that you would like to convert to rank change indicators.

palette

A character vector of length 3. Colors can be represented as hex values or named colors. Colors should be in the order of up-arrow, no-change, down-arrow, defaults to green, grey, purple.

fa_type

The name of the Fontawesome icon, limited to 5 types of various arrows, one of c("angles", "arrow", "turn", "chevron", "caret")

font_color

A string, indicating the color of the font, can also be returned as 'match' to match the font color to the arrow palette.

show_text

A logical indicating whether to show/hide the values in the column.

Value

a gt table

Examples

rank_table <- dplyr::tibble(x = c(1:3, -1, -2, -5, 0)) %>%
  gt::gt() %>%
  gt_fa_rank_change(x, font_color = "match")

Figures

fa_rank_change.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_badge(), gt_double_table(), gt_duplicate_column(), gt_fa_column(), 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.