Skip to contents

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