knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  warning = FALSE,
  message = FALSE,
  fig.path = "man/figures/README-",
  out.width = "100%"
)

tidyEmoji

R-CMD-check CRAN status Lifecycle: stable

The goal of tidyEmoji is to help R users work with text data with the presence of Emoji as easy as possible. The most common text data that falls into this category would be Tweets. When people tweet their emotions, ideas, celebrations, etc., Emoji sometimes appears on their Tweets, making the text rendered more colorful. To researchers/users who want to work with this type of text, it is intriguing to know the information about Emoji appearing in the text. With the help of tidyEmoji, dealing with Emoji is at ease.

Installation

Please install the released version of tidyEmoji from CRAN with:

install.packages("tidyEmoji")

Alternatively, you can install the latest development version from Github with:

# install.packages("devtools")
devtools::install_github("PursuitOfDataScience/tidyEmoji")

Usage

Here a tweet-like dataframe is created for brief demostration.

library(tidyEmoji)
library(dplyr)
tweet_df <- data.frame(tweets = c("I love tidyverse \U0001f600\U0001f603\U0001f603",
                                  "R is my language! \U0001f601\U0001f606\U0001f605",
                                  "This Tweet does not have Emoji!",
                                  "Wearing a mask\U0001f637\U0001f637\U0001f637\U0001f637.",
                                  "Emoji does not appear in all Tweets",
                                  "A flag \U0001f600\U0001f3c1"))

Emoji Tweets summary

Emoji Tweets are defined as Tweets containing at least one Emoji.

tweet_df %>%
  emoji_summary(tweets)

emoji_summary() gives an overview of how many Emoji Tweets and Tweet in total the data has.

tweet_df %>%
  emoji_tweets(tweets)

emoji_tweets() filters out non-Emoji Tweets while preserving the raw data structure.

Popular Emoji Tweets

tweet_df %>%
  top_n_emojis(tweets, n = 2)

top_n_emojis() returns a tibble about the most popular Emojis in the entire data. n is how many the most popular Emojis users want to output. By default, it is 20.

Emoji extraction

tweet_df %>%
  emoji_extract_unnest(tweets)

When looking at the tibble above, it has three columns: row_number, .emoji_unicode, and .emoji_count. row_number is which row each Tweet is located in the raw data. This can give users a global overview of Emoji and count.

emoji_extract_nest() is analogous to emoji_extract_unnest(), but it preserves the raw data with one extra column .emoji_unicode added.

tweet_df %>%
  emoji_extract_nest(tweets)

Emoji category

tweet_df %>%
  emoji_categorize(tweets)

Each Emoji Tweet is categorized based on the Emoji(s). If Emojis fall into various categories, the .emoji_category column has | to separate each category.

For more information about tidyEmoji, please refer to the package vignette for a comprehensive introduction.



PursuitOfDataScience/tidyEmoji documentation built on Aug. 22, 2023, 12:13 a.m.