search_emoji("smile")[1] "smiley" "smile" "sweat_smile" "smiley_cat" "smile_cat"
emoji(search_emoji("smile"))[1] "😃" "😄" "😅" "😺" "😸"
The emojifont package is designed to bring emoji font to R users. It packs emoji fonts and uses showtext to render the fonts so they can be used in base plots or ggplot2.
Get the released version from CRAN:
install.packages("emojifont")Or the development version from GitHub:
## install.packages("devtools")
devtools::install_github("GuangchuangYu/emojifont")To use emoji, we need to use their corresponding unicode. Emoji unicode can be found in https://apps.timwhitlock.info/emoji/tables/unicode, or searched using search_emoji. search_emoji returns emoji aliases which can be converted to unicode by emoji.
search_emoji("smile")[1] "smiley" "smile" "sweat_smile" "smiley_cat" "smile_cat"
emoji(search_emoji("smile"))[1] "😃" "😄" "😅" "😺" "😸"
set.seed(123)
x <- rnorm(10)
set.seed(321)
y <- rnorm(10)
plot(x, y, cex = 0)
text(x, y, labels = emoji("cow"), cex = 1.5, col = "steelblue", family = "OpenMoji")d <- data.frame(
x = x, y = y,
label = sample(c(emoji("cow"), emoji("camel")), 10, replace = TRUE),
type = sample(LETTERS[1:3], 10, replace = TRUE)
)
library(ggplot2)
ggplot(d, aes(x, y, color = type, label = label)) +
geom_text(family = "OpenMoji", size = 6)To make it easy to use with ggplot2, a simple layer geom_emoji is provided.
ggplot() + geom_emoji("rose", color = "steelblue") + theme_void()x <- seq(0, 2 * pi, length = 30)
y <- sin(x)
ggplot() + geom_emoji("heartbeat", x = x, y = y, size = 10)You can also use emoji within HTML tables by placing Unicode emoji into cells. Here we use knitr::kable() to render a simple table.
library(emojifont)
library(knitr)
df <- data.frame(
name = c("Cow", "Camel", "Heartbeat"),
emoji = emoji(c("cow", "camel", "heartbeat")),
stringsAsFactors = FALSE
)
kable(df, format = "html")| name | emoji |
|---|---|
| Cow | 🐮 |
| Camel | 🐫 |
| Heartbeat | 💓 |
The package also supports Font Awesome icons.
library(ggplot2)
set.seed(20160309)
fa <- fontawesome(c("fa-github", "fa-weibo", "fa-twitter", "fa-android", "fa-coffee"))
d <- data.frame(
x = rnorm(20),
y = rnorm(20),
label = sample(fa, 20, replace = TRUE)
)
ggplot(d, aes(x, y, color = label, label = label)) +
geom_text(family = "fontawesome-webfont", size = 6) +
xlab(NULL) + ylab(NULL) +
theme(legend.text = element_text(family = "fontawesome-webfont"))A corresponding geom_fontawesome is also provided.
ggplot() + geom_fontawesome("fa-github", color = "black") + theme_void()Creating phylomoji is possible using emojifont and ggtree, please refer to: https://yulab-smu.top/treedata-book/chapter8.html#phylomoji.
RStudio uses a different graphics device handling and showtext may be incompatible with it. Since emojifont uses showtext as backend to parse emoji font, it may also be incompatible with RStudio. Consider manually opening a device (X11() in Linux, quartz() in macOS or windows() in Windows).
Currently, this package supports Emoji Font and Font Awesome.
OpenMoji-Black.ttf is downloaded from https://github.com/hfg-gmuend/openmojifontawesome-webfont.ttf is downloaded from https://github.com/FortAwesome/Font-Awesome.Feel free to fork this package to add your favorite iconic fonts.
If you have any, let me know: https://github.com/GuangchuangYu/emojifont/issues.
Here is the output of sessionInfo() on the system on which this document was compiled:
sessionInfo()R version 4.6.0 (2026-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.51 ggplot2_4.0.3 emojifont_0.6.0
loaded via a namespace (and not attached):
[1] vctrs_0.7.3 cli_3.6.6 rlang_1.2.0 xfun_0.57
[5] showtextdb_3.0 sysfonts_0.8.9 proto_1.0.0 S7_0.2.2
[9] jsonlite_2.0.0 labeling_0.4.3 glue_1.8.1 buildtools_1.0.0
[13] htmltools_0.5.9 maketools_1.3.2 sys_3.4.3 scales_1.4.0
[17] rmarkdown_2.31 grid_4.6.0 evaluate_1.0.5 fastmap_1.2.0
[21] yaml_2.3.12 lifecycle_1.0.5 compiler_4.6.0 RColorBrewer_1.1-3
[25] farver_2.1.2 digest_0.6.39 R6_2.6.1 showtext_0.9-8
[29] withr_3.0.2 tools_4.6.0 gtable_0.3.6
ub.com/GuangchuangYu/emojifont/issues>.
Here is the output of sessionInfo() on the system on which this document was compiled:
sessionInfo()R version 4.6.0 (2026-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS
Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so; LAPACK version 3.12.0
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
time zone: Etc/UTC
tzcode source: system (glibc)
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] knitr_1.51 ggplot2_4.0.3 emojifont_0.6.0
loaded via a namespace (and not attached):
[1] vctrs_0.7.3 cli_3.6.6 rlang_1.2.0 xfun_0.57
[5] showtextdb_3.0 sysfonts_0.8.9 proto_1.0.0 S7_0.2.2
[9] jsonlite_2.0.0 labeling_0.4.3 glue_1.8.1 buildtools_1.0.0
[13] htmltools_0.5.9 maketools_1.3.2 sys_3.4.3 scales_1.4.0
[17] rmarkdown_2.31 grid_4.6.0 evaluate_1.0.5 fastmap_1.2.0
[21] yaml_2.3.12 lifecycle_1.0.5 compiler_4.6.0 RColorBrewer_1.1-3
[25] farver_2.1.2 digest_0.6.39 R6_2.6.1 showtext_0.9-8
[29] withr_3.0.2 tools_4.6.0 gtable_0.3.6