## remotes::install_github("matt-dray/emojiscape")
library(emojiscape)
tl;dr
You can print a little emoji scene to your R console with the {emojiscape} package.
Really?
Regular readers will know that this blog is where I implement whimsical R daydreams. Today is no exception: Iβve made a tiny package to print a little randomised emoji scene to my console.
Why? Iβve seen people make cute emoji-based bots, which Iβve been interested in after making the @londonmapbot Twitter bot (post, source, BotWiki). I also enjoyed the fun of mild randomisation in my last post about #RecreationThursday.
Iβve made this completely for my own amusement, so no guarantees whatsoever.
Play god
Install
You can install {emojiscape} from GitHub.
The package has one dependency: the GitHub-hosted {emo} package1 by Hadley Wickham. It implements emoji in R like emo::ji("sauropod")
π¦.
Thereβs no guarantee that these particular emoji will display correctly on your device and they may have different designs if youβre using another operating system.
Generate
Letβs generate()
a scene.
The first one is nuts, lol: a classic deciduous woods
.2
generate("woods")
π³ πΏ π° π° π³ πΏ π° π³ πΏ π°
π³ πΏ π³ π³ π° π³ π³ π° π° π³
π³ π° π³ π³ π³ π³ π° π³ π³ π³
π³ π³ π³ π³ π³ π³ π° π³ π³ π³
π³ πΏ π³ π° π³ π° π³ π³ π³ π³
π³ π³ πΏ π³ π³ π³ π³ π³ π° π³
π° πΏ π° πΏ π³ π³ πΏ π³ π³ π³
π³ π° π° π³ π³ π³ π³ π³ π³ π³
π³ π³ π³ π³ π³ π³ π³ π³ π³ π³
π³ π³ πΏ π³ π³ π³ π³ π³ π° πΏ
Hold your breath, weβre going to space
. You can resize the output, but space is basically infinite and my console is not.
generate(
terrain = "space",
grid_size = 7 # i.e. a 7x7 grid
)
β¬ β¬ β¬ β¬ β¬ β¬ β¬
β β¬ β¬ β¬ β β¬ β¬
β β β¬ β β¬ β¬ β¬
β¬ β¬ β β¬ β β¬ β¬
β¬ β¬ β¬ β¬ β¬ β¬ β¬
β¬ β¬ β¬ β π° β¬ β¬
β¬ β¬ β β β¬ β¬ β
Hereβs a little raccoon city
. Perhaps the residents are evil. (That is a gamer joke, gg.)
generate("city", 5)
π¬ π’ π’ π’ π’
π’ π¬ π¬ π’ π’
π’ π’ π¬ π’ π’
π’ π’ π’ π¬ π’
π’ π’ π¦ π’ π’
I have a PhD in dead leaves, so I had to add undergrowth
. Ant you glad I included it?
generate("undergrowth", 5)
π π π π π
π π π π π
π π π π π
π π π π π
π π π π π
Here endeth the puns.
Terrains
So what are all the available terrain options?
paste(as.list(args(generate))$terrain)[-1]
[1] "arable" "city" "desert" "forest" "garden"
[6] "liminal" "mountains" "ocean" "pastoral" "polar"
[11] "rainforest" "sky" "space" "suburbs" "traffic"
[16] "undergrowth" "woods"
This list may go out of date if more options are added in future.
Expand the sections below to see each terrainβs emoji set and previews of the output for each one.
Click for all emoji sets
terrain = "arable"
terrain name emoji freq
1 arable ear_of_corn π½ common
2 arable tractor π uncommon
3 arable mouse π rare
terrain = "city"
terrain name emoji freq
1 city office_building π’ common
2 city department_store π¬ uncommon
3 city raccoon π¦ rare
terrain = "desert"
terrain name emoji freq
1 desert desert π common
2 desert cactus π΅ uncommon
3 desert camel π« rare
terrain = "forest"
terrain name emoji freq
1 forest evergreen_tree π² common
2 forest squirrel πΏ uncommon
3 forest christmas_tree π rare
terrain = "garden"
terrain name emoji freq
1 garden rose πΉ common
2 garden seedling π± uncommon
3 garden wilted_flower π₯ rare
terrain = "liminal"
terrain name emoji freq
1 liminal white_large_square β¬ common
2 liminal door πͺ uncommon
3 liminal light_bulb π‘ rare
terrain = "mountains"
terrain name emoji freq
1 mountains mountain β° common
2 mountains snow_capped_mountain ποΈ uncommon
3 mountains goat π rare
terrain = "ocean"
terrain name emoji freq
1 ocean water_wave π common
2 ocean desert_island π uncommon
3 ocean dolphin π¬ rare
terrain = "pastoral"
terrain name emoji freq
1 pastoral rooster π common
2 pastoral egg π₯ uncommon
3 pastoral hatching_chick π£ rare
terrain = "polar"
terrain name emoji freq
1 polar cloud_with_snow π¨ common
2 polar snowflake βοΈ uncommon
3 polar penguin π§ rare
terrain = "rainforest"
terrain name emoji freq
1 rainforest deciduous_tree π³ common
2 rainforest snake π uncommon
3 rainforest gorilla π¦ rare
terrain = "sky"
terrain name emoji freq
1 sky cloud_with_rain π§ common
2 sky rainbow π uncommon
3 sky airplane βοΈ rare
terrain = "space"
terrain name emoji freq
1 space black_large_square β¬ common
2 space star β uncommon
3 space orbit π° rare
terrain = "suburbs"
terrain name emoji freq
1 suburbs deciduous_tree π³ common
2 suburbs house_with_garden π‘ uncommon
3 suburbs person_biking π΄ rare
terrain = "traffic"
terrain name emoji freq
1 traffic automobile π common
2 traffic taxi π uncommon
3 traffic truck π rare
terrain = "undergrowth"
terrain name emoji freq
1 undergrowth fallen_leaf π common
2 undergrowth ant π uncommon
3 undergrowth mushroom π rare
terrain = "woods"
terrain name emoji freq
1 woods deciduous_tree π³ common
2 woods chestnut π° uncommon
3 woods chipmunk πΏ rare
Click for all previews
terrain = "arable"
π½ π½ π½ π½ π½ π½ π½ π π½ π½
π½ π½ π½ π½ π½ π π π½ π½ π½
π π½ π½ π½ π½ π½ π½ π π½ π
π½ π π½ π½ π½ π½ π π½ π π½
π½ π½ π π½ π½ π½ π½ π π½ π½
π½ π½ π π½ π π½ π π½ π½ π
π½ π½ π½ π π½ π½ π π½ π½ π
π π½ π½ π½ π½ π½ π½ π½ π½ π½
π½ π½ π½ π½ π π½ π½ π½ π½ π½
π½ π π½ π π½ π½ π½ π½ π½ π½
terrain = "city"
π’ π’ π’ π’ π’ π’ π’ π¬ π’ π’
π’ π’ π’ π’ π’ π’ π’ π’ π’ π’
π’ π’ π’ π’ π¬ π¬ π’ π’ π’ π’
π’ π’ π’ π’ π’ π’ π¬ π’ π¬ π’
π’ π’ π¬ π’ π’ π’ π’ π’ π¦ π’
π’ π’ π¦ π¬ π’ π¦ π’ π¬ π’ π’
π¬ π’ π’ π¬ π’ π¬ π’ π’ π’ π¦
π’ π’ π’ π¬ π’ π’ π¬ π¬ π’ π’
π’ π’ π’ π¬ π’ π’ π’ π’ π¦ π¬
π’ π¬ π¬ π’ π’ π’ π’ π’ π’ π’
terrain = "desert"
π π π π π π΅ π π π π΅
π π π π π π π΅ π π π
π π π π π π π π π΅ π
π π΅ π π π΅ π π π π΅ π
π π π π π π π΅ π« π π
π΅ π π π π π π π π΅ π
π π π π π π΅ π π π π
π π π π π π π π π π
π π π π« π π΅ π΅ π π΅ π
π π π π« π« π π π΅ π΅ π«
terrain = "forest"
π² π² π² πΏ π² π² π² π² π π²
π² π² π² π² π² π² πΏ π² π² π²
π² π² π² π² π² π² π² π² π² π²
π² π² πΏ π² π² π² πΏ π² π² π²
πΏ π² π² π² π π² πΏ π² π² π
π² π² π² π² πΏ π² π² π π² π²
πΏ π² πΏ π² π π² πΏ π² πΏ π²
π² π² π² π² π² π² π² π² π² πΏ
π² π² π² π² π² π² π² π² π² π²
π² π² π² π² π² π² π² π² πΏ π²
terrain = "garden"
π± πΉ πΉ πΉ π± πΉ πΉ πΉ πΉ π±
πΉ πΉ πΉ πΉ π± πΉ πΉ π± π₯ πΉ
πΉ π± πΉ πΉ πΉ πΉ πΉ πΉ π₯ π±
π₯ π± πΉ π± πΉ πΉ πΉ πΉ πΉ πΉ
π± π₯ πΉ πΉ πΉ π₯ πΉ πΉ π± πΉ
πΉ πΉ π± πΉ πΉ πΉ π₯ πΉ πΉ πΉ
π± π± πΉ πΉ πΉ πΉ πΉ π± πΉ πΉ
πΉ πΉ π± πΉ πΉ πΉ πΉ πΉ π± πΉ
πΉ πΉ πΉ π± πΉ πΉ πΉ πΉ πΉ πΉ
π± πΉ π± πΉ πΉ πΉ πΉ πΉ πΉ π±
terrain = "liminal"
β¬ β¬ β¬ β¬ β¬ πͺ β¬ β¬ β¬ πͺ
β¬ β¬ β¬ β¬ β¬ β¬ πͺ β¬ β¬ β¬
β¬ β¬ β¬ β¬ β¬ β¬ β¬ β¬ πͺ β¬
β¬ β¬ β¬ β¬ πͺ β¬ β¬ β¬ β¬ β¬
β¬ πͺ β¬ β¬ πͺ πͺ β¬ πͺ β¬ β¬
β¬ πͺ β¬ β¬ π‘ β¬ β¬ πͺ β¬ β¬
β¬ πͺ πͺ πͺ β¬ β¬ β¬ β¬ β¬ β¬
β¬ β¬ β¬ β¬ β¬ β¬ β¬ πͺ β¬ β¬
β¬ β¬ πͺ β¬ πͺ β¬ πͺ β¬ β¬ β¬
β¬ πͺ πͺ β¬ πͺ β¬ β¬ β¬ β¬ β¬
terrain = "mountains"
β° β° β° π β° β° ποΈ β° β° β°
β° β° β° ποΈ β° β° ποΈ β° β° β°
β° ποΈ β° β° ποΈ β° β° β° β° β°
β° β° β° β° β° β° β° β° ποΈ β°
β° β° β° β° β° β° π β° β° π
β° π ποΈ β° β° β° β° β° ποΈ ποΈ
β° β° β° ποΈ π β° ποΈ ποΈ β° β°
β° ποΈ π β° β° β° β° β° β° β°
ποΈ β° β° β° β° ποΈ ποΈ β° ποΈ π
π ποΈ β° β° β° β° β° ποΈ β° ποΈ
terrain = "ocean"
π¬ π π π π π π π π π
π¬ π π π π π π¬ π π π
π π π π π π π π π π
π π π π π π π π π¬ π
π π π π π π π π π π
π π π¬ π π¬ π π π π π
π π π π π π π π π π
π π π π π π π π¬ π π
π π π π π π¬ π π π π
π π π π π π π π π π
terrain = "pastoral"
π π₯ π₯ π₯ π π π π π π
π π π π π£ π π₯ π π π£
π π π π π π π π π£ π
π π π₯ π π π π π π π£
π π£ π π π π π π π π
π₯ π π₯ π π π π π π£ π£
π π π π π π₯ π₯ π π£ π
π π π π₯ π π π π π π
π₯ π π π π₯ π₯ π₯ π π π
π₯ π π₯ π₯ π₯ π£ π π₯ π π₯
terrain = "polar"
π¨ βοΈ βοΈ π¨ βοΈ π¨ π¨ π¨ βοΈ π¨
π¨ π¨ π¨ π¨ π¨ π¨ βοΈ π¨ π¨ π¨
π¨ π¨ π§ π¨ βοΈ π§ π¨ βοΈ βοΈ π¨
βοΈ π¨ π¨ π¨ π¨ π¨ βοΈ π¨ βοΈ π¨
π¨ π¨ βοΈ π§ βοΈ βοΈ βοΈ π¨ π¨ βοΈ
π¨ π¨ π¨ π¨ π¨ βοΈ π¨ π¨ π¨ βοΈ
π¨ βοΈ π¨ π¨ π¨ βοΈ π¨ π¨ π¨ π¨
π¨ π¨ π§ βοΈ π¨ βοΈ π¨ π¨ βοΈ π¨
π¨ π¨ π¨ π¨ βοΈ π¨ π¨ π¨ π¨ π¨
π¨ βοΈ π¨ π¨ π¨ π¨ π¨ π§ βοΈ π¨
terrain = "rainforest"
π³ π³ π³ π³ π³ π³ π¦ π³ π³ π³
π³ π π π π³ π¦ π³ π³ π³ π³
π³ π³ π³ π³ π¦ π³ π¦ π³ π³ π
π³ π³ π³ π³ π³ π³ π³ π π³ π³
π³ π³ π π¦ π³ π³ π³ π π³ π
π³ π³ π π³ π π³ π π³ π³ π³
π³ π³ π³ π³ π π³ π³ π³ π³ π³
π π³ π³ π³ π¦ π³ π³ π³ π³ π³
π³ π³ π¦ π³ π³ π³ π³ π π³ π
π π³ π³ π π³ π³ π π³ π³ π³
terrain = "sky"
π§ π§ π§ π§ π§ π§ π§ π§ π π
π§ π§ π§ π§ π§ π π§ π§ π π§
π§ π§ π π§ βοΈ π§ π§ π§ π§ βοΈ
π§ π§ π§ βοΈ π§ π§ π§ π§ π§ π
π§ π§ π§ π§ π π§ π§ π§ π§ π§
π π§ π§ π§ π§ π§ π§ π π§ π§
π§ π π§ π§ π§ π§ π§ π§ π§ π§
π§ π§ π§ π§ π π§ π§ βοΈ π π
βοΈ π§ π§ π§ π§ π§ π§ π§ π π
π π§ π§ π§ π§ π§ π π§ π π§
terrain = "space"
β¬ β¬ β¬ β¬ β¬ β¬ β¬ β¬ β¬ β
β¬ β¬ β β¬ β¬ β¬ β¬ β β¬ β¬
β¬ β¬ β¬ β β β¬ β β β¬ β¬
β β¬ β¬ β β¬ π° β¬ π° β¬ β
β¬ β¬ β¬ π° β β¬ β¬ π° β¬ β
β β¬ β β¬ β¬ β¬ β¬ β¬ β β¬
β¬ β¬ β β¬ β¬ β¬ β¬ β¬ β¬ β
β β β¬ β¬ β β¬ β¬ β¬ β β¬
β¬ β¬ β¬ β¬ β β¬ β¬ β¬ β β
β β¬ β β¬ π° β¬ β¬ β¬ β¬ β¬
terrain = "suburbs"
π³ π³ π‘ π³ π³ π³ π³ π³ π³ π³
π³ π‘ π³ π³ π‘ π³ π‘ π³ π΄ π‘
π³ π³ π‘ π³ π³ π‘ π³ π³ π³ π³
π³ π³ π³ π³ π‘ π³ π³ π΄ π³ π³
π³ π³ π‘ π‘ π³ π‘ π³ π‘ π³ π³
π³ π³ π‘ π³ π³ π‘ π³ π‘ π³ π‘
π³ π‘ π³ π‘ π³ π³ π‘ π‘ π³ π‘
π³ π³ π³ π³ π³ π΄ π‘ π³ π‘ π³
π³ π³ π³ π΄ π³ π³ π³ π‘ π³ π³
π³ π‘ π³ π‘ π³ π³ π‘ π‘ π³ π³
terrain = "traffic"
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
terrain = "undergrowth"
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
π π π π π π π π π π
terrain = "woods"
π³ π³ π³ π° π° π³ π³ π³ π³ π³
π³ π° π³ π° π³ π° π³ π³ π³ π³
π³ π° π° π³ π³ πΏ π³ π³ πΏ π³
π° π³ π³ π³ π³ π° π³ π³ π° π³
π° π³ π° π³ π³ π³ π³ π³ π³ π°
π³ π³ π³ π³ π³ π³ π³ π° π³ π³
π³ π³ π³ π³ π³ π³ πΏ π° π³ π³
π³ π³ π° π° π° π³ π° π³ π³ π°
π³ π³ π° π° π³ π³ π³ π³ π³ π°
π³ π³ π³ π³ π³ π³ π³ π³ π³ π³
Frequencies
Use get_set()
to see each terrainβs emoji set and their βsuggested frequencyβ slot. In general, the most common emoji is the one that defines the background or vegetation and the rarer ones are creatures or whatever.
get_set("mountains")
terrain name emoji freq
1 mountains mountain β° common
2 mountains snow_capped_mountain ποΈ uncommon
3 mountains goat π rare
But you can totally mess with these emoji sampling probabilities in generate()
.
Any The Mountain Goats fans?
generate(
terrain = "mountains",
prob_common = 0.1,
prob_uncommon = 0.2,
prob_rare = 0.7 # INCREASE GOAT FREQUENCY
)
π ποΈ π β° π π π ποΈ π π
ποΈ π β° π π π π ποΈ π π
π π ποΈ π π π β° π π π
π π π π β° π π ποΈ π π
π π π π ποΈ π π π β° π
π π π π ποΈ π ποΈ π π π
ποΈ π β° ποΈ π π β° π β° π
π π π β° π β° π ποΈ π ποΈ
ποΈ π π π π π ποΈ ποΈ ποΈ ποΈ
ποΈ ποΈ β° π π ποΈ π π ποΈ π
Approach
The generate()
function is pretty simple. What it does is:
- Creates a vector of emojis with a length of
grid_size()
squared, sampled from the specifiedterrain
set with frequencies from theprob_*
arguments - Coerces this vector to a matrix of length and width
grid_size()
(i.e. a square) - Loops over each row of the matrix with
cat()
to print the output to the console
It works.
Expansion
If you really want, you can add a terrain
option by raising a new issue or pull request in the {emojiscape} GitHub repo. These are specified in the .get_emoji()
function in the /R/utils.R script.
Environment
Session info
Last rendered: 2023-07-17 18:35:09 BST
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Ventura 13.2.1
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib; LAPACK version 3.11.0
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
time zone: Europe/London
tzcode source: internal
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] emojiscape_0.0.0.9000
loaded via a namespace (and not attached):
[1] digest_0.6.31 assertthat_0.2.1 lubridate_1.9.2 fastmap_1.1.1
[5] xfun_0.39 magrittr_2.0.3 glue_1.6.2 stringr_1.5.0
[9] knitr_1.43.1 htmltools_0.5.5 timechange_0.2.0 generics_0.1.3
[13] rmarkdown_2.23 lifecycle_1.0.3 cli_3.6.1 vctrs_0.6.3
[17] compiler_4.3.1 purrr_1.0.1 emo_0.0.0.9000 rstudioapi_0.15.0
[21] tools_4.3.1 evaluate_0.21 yaml_2.3.7 crayon_1.5.2
[25] rlang_1.1.1 jsonlite_1.8.7 htmlwidgets_1.6.2 stringi_1.7.12