Skip to contents

The gt_fa_column function takes an existing gt_tbl object and adds specific fontawesome icons based on what the names in the column are. The icons are colored according to a palette that the user supplies, either a vector of valid colors/hex colors of length equal to the unique levels.

Usage

gt_fa_column(
  gt_object,
  column,
  ...,
  palette = NULL,
  align = "left",
  direction = 1
)

Arguments

gt_object

An existing gt table object of class gt_tbl

column

The column wherein the character strings should be replaced with their corresponding {fontawesome} icons.

...

Additional arguments passed to fontawesome::fa()

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")

align

Character string indicating alignment of the column, defaults to "left"

direction

The direction of the paletteer palette, should be either -1 for reversed or the default of 1 for the existing direction.

Value

An object of class gt_tbl.

Examples

library(gt)
fa_cars <- mtcars %>%
  head() %>%
  dplyr::select(cyl, mpg, am, gear) %>%
  dplyr::mutate(man = ifelse(am == 1, "cog", "cogs")) %>%
  gt() %>%
  gt_fa_column(man)

Figures

Function ID

2-15