Skip to contents

Add rating "stars" to a gt column

Usage

gt_fa_rating(
  gt_object,
  column,
  max_rating = 5,
  ...,
  color = "orange",
  icon = "star"
)

Arguments

gt_object

An existing gt table object of class gt_tbl

column

The column wherein the numeric values should be replaced with their corresponding {fontawesome} icons.

max_rating

The max number of icons to add, these will be added in grey to indicate "missing"

...

Additional arguments passed to fontawesome::fa()

color

The color of the icon, accepts named colors ("orange") or hex strings.

icon

The icon name, passed to fontawesome::fa()

Value

An object of class gt_tbl.

Examples

library(gt)
set.seed(37)
rating_table <- mtcars %>%
  dplyr::select(mpg:wt) %>%
  dplyr::slice(1:5) %>%
  dplyr::mutate(rating = sample(1:5, size = 5, TRUE)) %>%
  gt() %>%
  gt_fa_rating(rating, icon = "r-project")

Figures

Function ID

2-16