Fontawesome icons not rendering correctly in gt_fa_column()

I'm trying to put fontawesome icons into a gt table, but the icons don't seem to be rendering in the output.

Code is below:

  # load package(s)
  library(gt)
  library(gtExtras)
  library(tidyverse)
  library(fontawesome)

stream_data  = read_csv("data/stream_data.csv")

stream_data %>%
  gt() %>%
  gt_fa_column(type) %>%
  gt_plt_bullet(column = nominee, target = winner) %>%
  fmt_number(scale_by = 100, decimals = 1) %>%
  fmt_symbol_first(column = ratio, symbol = "%") %>%
  gt_theme_nytimes()

I'm doing this in a Quarto markdown document, and I get something like this in each cell:

list(name = "div", attribs = list(title = "wifi", aria-label = "wifi", role = "img", style = "padding:0px"), children = list(list("")))

when I'm supposed to get this:
Screenshot 2024-03-01 at 4.51.57 PM

I'm not sure what's going wrong because someone else used the same exact code and it was working. Does anyone have any ideas?

1 Like

I can reproduce using

---
title: test
format: html
---

```{r}
library(gt)
library(gtExtras)
fa_cars <- mtcars %>%
  head() %>%
  dplyr::select(cyl, mpg, am, gear) %>%
  dplyr::mutate(man = ifelse(am == 1, "gear", "gears")) %>%
  gt() %>%
  gt_fa_column(man)
fa_cars
```

(I don't have your data files, so your example is not reproducible)

But this happens also with R Makrodwn on my side

---
title: "Test"
date: "`r Sys.Date()`"
output: html_document
---

```{r}
library(gt)
library(gtExtras)
fa_cars <- mtcars %>%
  head() %>%
  dplyr::select(cyl, mpg, am, gear) %>%
  dplyr::mutate(man = ifelse(am == 1, "gear", "gears")) %>%
  gt() %>%
  gt_fa_column(man)
fa_cars
```

So this seems to be either gt or gtExtras

And I also get it in console

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

cc @Richard_Iannone @tom_rstudio

Do you know enough about gt and gtExtras to have an idea ?

I also see this locally and will explore at the gtExtras level -- @gwang do you mind opening an issue at: GitHub - jthomasmock/gtExtras: A Collection of Helper Functions for the gt Package.?

Alternatively, there is now a fmt_icon() function in gt proper:

mtcars %>%
  head() %>%
  dplyr::select(cyl, mpg, am, gear) %>%
  dplyr::mutate(man = ifelse(am == 1, "gear", "gears")) %>%
  gt() %>%
  gt::fmt_icon(man)

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.