library("dplyr")
Happy World Emoji Day: an analysis of rOpenSci’s Slack emojis
HAPPY world emoji day! 🌐 🐔 📆
In honor of this momentous occasion, I have decided to analyze the emojis used on rOpenSci’s Slack.
If you’d like to follow along, go fetch yourself a Slack token.
<- "MY_SLACK_API_TOKEN" ## stick your token here token
We will first use Slack’s reactions.list
method.
Notice here I am pulling the items from the response and then from each item I am interested in the message reactions. This ignores the reactions on files and comments.
<- httr::POST(
req_lst "https://slack.com/api/reactions.list",
body = list(
token = token,
count = 500
%>%
)) ::content() %>%
httr$items %>%
.::map(~.[["message"]][["reactions"]]) purrr
Let’s pull out the name
and count
of each emoji used and stick it in a tibble
🎉.
<- tibble::tibble(
tbl name = purrr::map_chr(purrr::flatten(req_lst), "name"),
count = purrr::map_int(purrr::flatten(req_lst), "count")
)
One of the most delightful features in Slack is the ability to create custom emojis! In order to be able to display both ordinary and custom emojis, I can pull in a list of all emojis we have customized in the rOpenSci Slack team using the emoji.list
method.
Notice here I am using the tibble::enframe()
function. This is an awesome way to convert a vector or list to a two-column data frame.
<- httr::POST(
emojis_tbl "https://slack.com/api/emoji.list",
body = list(token = token)
%>%
) ::content() %>%
httr$emoji %>%
.::enframe() %>%
tibblemutate(value = unlist(value))
The emojis_tbl
data frame contains the name of each custom emoji and a link to their associated image. Here I create a small function that will either read that image using the magick
package or, if it is an ordinary emoji, use the emo
package to look it up.
<- function(x, y) {
read_emoji if (!is.na(x)) {
::image_read(x)
magickelse {
} ::ji(y)
emo
} }
Let’s do a wee bit of data wrangling 🚜 to sort out which emojis are used the most.
<- tbl %>%
top_emojis group_by(name) %>%
summarise(count = sum(count)) %>%
arrange(desc(count)) %>%
slice(1:10) %>%
left_join(emojis_tbl, by = "name") %>%
mutate(emoji = purrr::map2(value, name, read_emoji))
I have written another small function to make sure the custom emojis print properly when I render my output.
Note, if you are doing this for your blog, rather than saving a temporary file as I have demonstrated here, you should save this as a relative file path in your blog 🌳.
<- function(x, y) {
render_emoji if (inherits(x, "magick-image")) {
<- tempfile(fileext = ".gif")
tmp <- magick::image_scale(x, "25x25")
x ::image_write(x, path = tmp)
magick<- rep(glue::glue("![]({tmp})"), as.integer(y/7))
emoji print(glue::glue("{glue::glue_collapse(emoji)}: {y}\n\n"))
else {
} <- rep(x, as.integer(y/7))
emoji print(glue::glue("{glue::glue_collapse(emoji)}: {y}\n\n"))
} }
Now let’s walk it out 💃.
::walk2(top_emojis$emoji, top_emojis$count, render_emoji) purrr
[1] “👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋👋: 130”
[2] “👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍👍: 129”
[3] “❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️❤️: 83”
[4] “: 75” [5] “🎉🎉🎉🎉🎉🎉🎉🎉🎉: 65”
[6] “🐓🐓🐓🐓🐓: 36”
[7] “😂😂😂😂: 34”
[8] “➕➕➕➕: 29”
[9] “🍻🍻🍻🍻: 28”
[10] “: 27”
How delightful! It is no surprise that the 👋 is the most popular emoji used, since rOpenSci is an extraordinarily welcoming crew! In fact the community organizer, Stefanie, just wrote a blog post about our Slack #welcome channel. I am (obviously) very proud to see that 🐓 makes a strong appearance (#rchickenladies), and of course delighted to see our Aussie friends getting represented by the Aussie party parrot.