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:

library(tidyverse)

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

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: https://stackoverflow.com/a/52059455

Unfortunately not. Thanks though.

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

emojitable

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"
output:
  html_document:
    df_print: paged
  pdf_document: default
---
```{r include=FALSE}
library(tidyverse)
library(gt)
library(emo) #devtools::install_github("hadley/emo")
```


```{r}

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

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.