New sports from random emoji

November 24, 2017
By

(This article was first published on Rstats on Julia Silge, and kindly contributed to R-bloggers)

I love emoji ❤️ and I love xkcd, so this recent comic from Randall Munroe was quite a delight for me.

I sat there, enjoying the thought of these new sports like horse hole and multiplayer avocado and I thought, “I can make more of these in just the barest handful of lines of code”. This is largely thanks to the emo package by Hadley Wickham, which if you haven’t installed and started using yet, WHY NOT??? ?

emoji_sports <- function(n) {
    data <- dplyr::sample_n(emo::jis, n)
    emo::ji_glue(paste(dplyr::pull(data, emoji),
                       collapse = ""))
}

This function uses the jis dataset from the emo package, sample a few of them, and then prints them out in a R Markdown document, which is what I use to blog. Let’s make some!

?????‍♂️

Excellent. This new sport is a head injury formalwear competition; it’s judged very strictly.

?????‍♀️

Here we see the new sport of being thankful for Senegalese culture.

⭐️??

This new sport is a scary one, where stars are awarded to the baby chicks with the best knife-throwing skills.

Some of the sports in the xkcd comic have only two characters, and we can make those as well.

????‍♂️

Ah yes, we’ll soon all be enjoying the sport of running long distances for no understandable reason. I think some of you probably already enjoy this sport.

Or we can generate lots with purrr.

library(purrr)

map(sample(c(2,3), 10, replace = TRUE),
    emoji_sports)
## [[1]]
## ?️??‍♀️ 
## 
## [[2]]
## ???‍♀️?? 
## 
## [[3]]
## ⚾?? 
## 
## [[4]]
## ???️??‍♂️ 
## 
## [[5]]
## ??☃✡ 
## 
## [[6]]
## ?️?️?? 
## 
## [[7]]
## ??? 
## 
## [[8]]
## ??‍♂️??? 
## 
## [[9]]
## ☂↘️✋ 
## 
## [[10]]
## ?️??‍♂️

Some of those emojis aren’t printing quite as well, but there are definitely some winners (timed spiderweb fingerknitting and the like).

I could keep going all day, but I’ll wrap it up here. ? Let me know if you have any questions!

To leave a comment for the author, please follow the link and comment on their blog: Rstats on Julia Silge.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.

Search R-bloggers

Sponsors

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)