Each emoji can be specified with a code. You can make use of the emoji_search
function to look for the code of the emoji you want to add.
# install.packages("remotes")
# remotes::install_github("dill/emoGG")
library(emoGG)
# Search for a emoji
emoji_search("flower")
emoji | code | keyword | |
---|---|---|---|
1928 | wilted_flower | 1f940 | flower |
1940 | cherry_blossom | 1f338 | flower |
2748 | rosette | 1f3f5 | flower |
4130 | o | 2b55 | circle |
4131 | o | 2b55 | round |
5234 | eritrea | 1f1ea | er |
In the previous section we looked for emojis related with flowers. If you choose the cherry_blossom
emoji you have to pass its code to the geom_emoji
function as follows.
# install.packages("remotes")
# remotes::install_github("dill/emoGG")
library(emoGG)
# install.packages("ggplot2")
library(ggplot2)
# Plot
ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_emoji(emoji = "1f938")
Other example can be adding diamonds to the diamonds
dataset. In this case the corresponding code is "1f48e"
.
# install.packages("remotes")
# remotes::install_github("dill/emoGG")
library(emoGG)
# install.packages("ggplot2")
library(ggplot2)
# Sample of diamonds data set
set.seed(5)
dmnds <- diamonds[sample(nrow(diamonds), 800), ]
# Plot with real diamonds
ggplot(dmnds, aes(carat, price)) +
geom_emoji(emoji = "1f48e")
The package comes with an additional function named add_emoji
, which allows you to add any emoji as a background. In the following example we are adding a car to a scatter plot made with the mtcars
dataset.
# install.packages("remotes")
# remotes::install_github("dill/emoGG")
library(emoGG)
# install.packages("ggplot2")
library(ggplot2)
# Plot with car
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
add_emoji(emoji = "1f697")
See also