YouTube content frequently
contains emojis, special Unicode characters, and text in various
languages. The tuber package provides built-in functions
for detecting, extracting, and manipulating emojis without external
dependencies.
library(tuber)
# Get comments from a video
comments <- get_all_comments(video_id = "your_video_id")
# Check which comments contain emojis
comments$has_emoji <- has_emoji(comments$text_display)
# Count emojis per comment
comments$emoji_count <- count_emojis(comments$text_display)
# Filter to emoji-rich comments
emoji_comments <- comments[comments$emoji_count > 0, ]The package provides five main functions for working with emojis:
has_emoji() - Check for emoji presencecount_emojis() - Count emojis in textextract_emojis() - Get emojis from textremove_emojis() - Strip emojis from textYour R environment may not support UTF-8 display. The data is still correct; only the display is affected. Try:
An emoji is counted once however many code points encode it. A
family, a flag, a keycap, or a thumbs-up with a skin tone is one emoji.
tuber finds emoji per user-perceived character using the
Unicode data that ships with the stringi package, so there
is no list of emoji inside tuber to go out of date.
Text symbols such as the copyright sign, and plain digits, count as emoji only when the text presents them as one (a keycap digit, or a symbol followed by the emoji variation selector).