How do I get an emoji to show up in a table? 🤷‍♂️

Hey, I have a bunch of data in a .csv file, some strings of which include emojis in them. When I readr::read_csv it, then emojis show up like so \U0001f36b in the console. After I do my wranglings and whatnot and knit an HTML page displaying the table with formattable::formattable, the emojis look like this: <U+0001F36B> .

Here's a reprex to put in an .Rmd and knit as HTML:


tibble(a = 2021, b = 1, c = "Seattle SuperSonics 🍫", d = 0, e = 0, f = 0) %>% 

To me it returns this:

Obviously, what I'd want is this:

1 Like

I am pretty sure this will solve it for you. Have a look here:

Unfortunately not. Thanks though.

tibble(a = 2021, b = 1, c = "Seattle SuperSonics 🍫", 
       d = 0, e = 0, f = 0) %>% gt()


gt is an improvement on formattable as it will show the emoji in the Viewer pane but still not after knitting.

I guess ultimately it's a Windows encoding issue and it gets changed somewhere along the chain. Works as I'd like it to on Mac/Linux.

I'm using windows and I tested that the following succesfully knits to html.

title: "R Notebook"
    df_print: paged
  pdf_document: default
```{r include=FALSE}
library(emo) #devtools::install_github("hadley/emo")


tibble(a = 2021, b = 1, 
       c = paste0("Seattle SuperSonics ", emo::ji("chocolate")), 
       d = 0, e = 0, f = 0) %>% gt() 

This topic was automatically closed 7 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.