Title: | Data and Function to Work with Emojis |
---|---|
Description: | Contains data about emojis with relevant metadata, and functions to work with emojis when they are in strings. |
Authors: | Emil Hvitfeldt [aut, cre] , Hadley Wickham [ctb] (Data parsing code from hadley/emo), Romain François [ctb] (Data parsing code from hadley/emo) |
Maintainer: | Emil Hvitfeldt <[email protected]> |
License: | MIT + file LICENSE |
Version: | 16.0.0 |
Built: | 2024-10-29 06:52:15 UTC |
Source: | CRAN |
Insert Arrow emojis
arrow(direction)
arrow(direction)
direction |
Character denoting the direction of the arrow. Should be one of “up”, “up-right”, “right”, “down-right”, “down”, “down-left”, “left”, “up-left”, “up-down”, or “left-right”. |
This function is vectorized. Wrong input of direction
will result in NA
s.
#@return Character vector of emojis.
arrow("up-down") arrow(c("up", "up", "down", "down", "left", "right", "left", "right"))
arrow("up-down") arrow(c("up", "up", "down", "down", "left", "right", "left", "right"))
emoji version of time
clock(time)
clock(time)
time |
a |
This function is vectorized.
Character vector of emojis showing the closest time.
times <- as.POSIXct("2021-09-17 14:33:21 PDT") + seq(1:30) * 3500 clock(times)
times <- as.POSIXct("2021-09-17 14:33:21 PDT") + seq(1:30) * 3500 clock(times)
This function starts by looking for exact matches in emoji_name
. If none is
found in emoji_name
then it looks in emoji_keyword
. emoji_keyword
can
produce more then 1 matches, which will lead to one being returned at random.
emoji(keyword)
emoji(keyword)
keyword |
Character, either name or keyword. If more than one emoji has the specified keyword, will pick one at random. |
This function isn't vectorized and will thus only work with 1 keyword at a time.
emoji("smile") emoji("taco") set.seed(1234) replicate(24, emoji("clock")) replicate(10, emoji("flag"))
emoji("smile") emoji("taco") set.seed(1234) replicate(24, emoji("clock")) replicate(10, emoji("flag"))
Vectorised over string
emoji_count(string)
emoji_count(string)
string |
Input vector |
An integer vector
string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_count(string) emoji_count(emoji_name[1:6])
string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_count(string) emoji_count(emoji_name[1:6])
Vectorised over string
emoji_detect(string, negate = FALSE)
emoji_detect(string, negate = FALSE)
string |
Input vector. Either a character vector, or something coercible to one. |
negate |
If |
A logical vector
string <- c(letters[1:4], emoji_name[1:6]) emoji_detect(string)
string <- c(letters[1:4], emoji_name[1:6]) emoji_detect(string)
vectorised over string
emoji_extract(string) emoji_extract_all(string, simplify = FALSE)
emoji_extract(string) emoji_extract_all(string, simplify = FALSE)
string |
Input vector. |
simplify |
A character vector
stringr::str_extract()
and stringr::str_extract_all()
chars <- c(letters[1:4], emoji_name[1:6]) set.seed(1234) strings <- lapply(1:10, function(x) paste(sample(chars, x), collapse = "")) extracts <- emoji_extract(strings) all_extracts <- emoji_extract_all(strings)
chars <- c(letters[1:4], emoji_name[1:6]) set.seed(1234) strings <- lapply(1:10, function(x) paste(sample(chars, x), collapse = "")) extracts <- emoji_extract(strings) all_extracts <- emoji_extract_all(strings)
This function will look in emoji_keyword
to report back the given emojis.
emoji_find(keyword)
emoji_find(keyword)
keyword |
Character, Emoji keyword. |
emoji_find("happy") emoji_find("cat") emoji_find("family")
emoji_find("happy") emoji_find("cat") emoji_find("family")
Some emojis can be written in multiple different ways either as
fully-qualified
, minimally-qualified
, or unqualified
. emoji_fix()
will take any emoji and return the fully-qualified
version of that emoji.
emoji_fix(x)
emoji_fix(x)
x |
Characters, vector of emojis. |
This function is vectorized.
vector of fully-qualified emojis
unqualified_ind <- which(emojis$qualified == "unqualified")[1:10] unqualified <- emojis$emoji[unqualified_ind] unqualified emoji_fix(unqualified)
unqualified_ind <- which(emojis$qualified == "unqualified")[1:10] unqualified <- emojis$emoji[unqualified_ind] unqualified emoji_fix(unqualified)
Combine the power of glue::glue
and emoji()
.
emoji_glue(..., .envir = parent.frame())
emoji_glue(..., .envir = parent.frame())
... |
[ For |
.envir |
[ |
emoji_glue()
behaves in much the same way a lot of messaging apps work.
Anything inside a pair of :
will be interpolated into an emoji.
You can think of emoji_glue()
as being a shorthand for
glue("I love {emoji('taco')}s")
.
Block ending with *
will be collapsed.
a glue::glue()
string.
emoji_glue("I love :taco:s") emoji_glue("one :heart:") emoji_glue("many :heart*:")
emoji_glue("I love :taco:s") emoji_glue("one :heart:") emoji_glue("many :heart*:")
This list contains information about which emojis are contained in which keywords.
emoji_keyword
emoji_keyword
named list of characters with 7665 elements
Unicode® Full Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/full-emoji-list.html
Unicode® Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/emoji-list.html
Unicode® Emoji Ordering, v16.0 - https://www.unicode.org/emoji/charts/emoji-ordering.txt#' @source https://github.com/github/gemoji
https://github.com/muan/emojilib
emojis emoji_name
Vectorised over string
emoji_locate(string) emoji_locate_all(string)
emoji_locate(string) emoji_locate_all(string)
string |
Input vector |
For emoji_locate
an integer matrix, for emoji_locate_all
a list
of integer matrices
string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_locate(string) emoji_locate_all(string)
string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_locate(string) emoji_locate_all(string)
Vectorized over string
emoji_match(string) emoji_match_all(string)
emoji_match(string) emoji_match_all(string)
string |
Input vector |
chars <- c(letters[1:4], emoji_name[1:6]) set.seed(1234) strings <- lapply(1:10, function(x) paste(sample(chars, x), collapse = "")) extracts <- emoji_match(strings) extracts <- emoji_match_all(strings)
chars <- c(letters[1:4], emoji_name[1:6]) set.seed(1234) strings <- lapply(1:10, function(x) paste(sample(chars, x), collapse = "")) extracts <- emoji_match(strings) extracts <- emoji_match_all(strings)
Extract Modifiers from Emojis
emoji_modifier_extract(x)
emoji_modifier_extract(x)
x |
Characters, vector of emojis. |
This function is vectorized. See emoji_modifiers for full list of modified emojis and their unmodified state.
list of character vectors.
waving_hands <- emojis$emoji[grepl("waving hand", emojis$name)] waving_hands emoji_modifier_extract(waving_hands) set.seed(1234) emoji_sample <- sample(emojis$emoji, 10) emoji_sample emoji_modifier_extract(emoji_sample)
waving_hands <- emojis$emoji[grepl("waving hand", emojis$name)] waving_hands emoji_modifier_extract(waving_hands) set.seed(1234) emoji_sample <- sample(emojis$emoji, 10) emoji_sample emoji_modifier_extract(emoji_sample)
Remove Modifiers from Emojis
emoji_modifier_remove(x)
emoji_modifier_remove(x)
x |
Characters, vector of emojis. |
This function is vectorized. See emoji_modifiers for full list of modified emojis and their unmodified state.
character vector, single emojis will be replaced with un-modified if possible.
waving_hands <- emojis$emoji[grepl("waving hand", emojis$name)] waving_hands emoji_modifier_remove(waving_hands) set.seed(1234) emoji_sample <- sample(emojis$emoji, 10) emoji_sample emoji_modifier_remove(emoji_sample)
waving_hands <- emojis$emoji[grepl("waving hand", emojis$name)] waving_hands emoji_modifier_remove(waving_hands) set.seed(1234) emoji_sample <- sample(emojis$emoji, 10) emoji_sample emoji_modifier_remove(emoji_sample)
This data set contains all the emojis with modifiers, their unmodified version as well as a list of the the modifiers.
emoji_modifiers
emoji_modifiers
tibble with 3 columns and
nrow(emoji_modifiers)
rows
character representation of the emoji with modifiers
character representation of the emoji without modifiers
list of modifiers
Unicode® Full Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/full-emoji-list.html
Unicode® Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/emoji-list.html
Unicode® Emoji Ordering, v16.0 - https://www.unicode.org/emoji/charts/emoji-ordering.txt#' @source https://github.com/github/gemoji
https://github.com/muan/emojilib
emojis emoji_name
This vector is a named vector of emojis, where then names are unique descriptive identifiers for the emojis. This vector is well suited to be used as a tool to replace emojis with natural language descriptions.
emoji_name
emoji_name
named character vector with 4698 elements
Some emojis will appear multiple times since they have multiple names associated with them. Such as "grinning" and "grinning_face" leading to the same emoji.
Unicode® Full Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/full-emoji-list.html
Unicode® Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/emoji-list.html
Unicode® Emoji Ordering, v16.0 - https://www.unicode.org/emoji/charts/emoji-ordering.txt#' @source https://github.com/github/gemoji
https://github.com/muan/emojilib
emojis emoji_keyword
Summarise your p-values with emoji
emoji_p( x, names = c("laughing", "joy", "grin", "smile", "thinking", "poop"), cutpoints = c(1e-05, 0.001, 0.01, 0.05, 0.1), legend = FALSE )
emoji_p( x, names = c("laughing", "joy", "grin", "smile", "thinking", "poop"), cutpoints = c(1e-05, 0.001, 0.01, 0.05, 0.1), legend = FALSE )
x |
A vector of p-values. |
names |
A character vector, for each of the p-value cutoff points.
The names are being passed to |
cutpoints |
A numeric vector of cutpoints between emojis. |
legend |
Logical, denotes if the result should be returned with a legend. |
This function is vectorized. The input cutpoints
must be 1 shorter than the
names
input. The input cutpoints
should not include 0 or 1 and be in
accending order.
set.seed(1234) emoji_p(1) emoji_p(0.1) emoji_p(0.05) emoji_p(0.01) emoji_p(1e-6) emoji_p(0.01, legend = TRUE) emoji_p(rbeta(50, 2, 5)) emoji_p( runif(100, 0, 0.1), names = c("biceps", "hundred", "thumbs_down", "thumbs_up"), cutpoints = c(0.001, 0.01, 0.05) )
set.seed(1234) emoji_p(1) emoji_p(0.1) emoji_p(0.05) emoji_p(0.01) emoji_p(1e-6) emoji_p(0.01, legend = TRUE) emoji_p(rbeta(50, 2, 5)) emoji_p( runif(100, 0, 0.1), names = c("biceps", "hundred", "thumbs_down", "thumbs_up"), cutpoints = c(0.001, 0.01, 0.05) )
Vectorised over string
and replacement
emoji_replace(string, replacement) emoji_replace_all(string, replacement)
emoji_replace(string, replacement) emoji_replace_all(string, replacement)
string |
Input vector |
replacement |
A character vector of replacements. Should either be
of length 1 or the same length as |
A character vector
emoji_replace(emoji_name[1], "_emoji_") string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_replace_all(emoji_name[1:6], "_emoji_")
emoji_replace(emoji_name[1], "_emoji_") string <- paste(c(letters[1:4], emoji_name[1:6]), collapse = " ") emoji_replace_all(emoji_name[1:6], "_emoji_")
Vectorised over string
emoji_replace_name(string)
emoji_replace_name(string)
string |
Input vector |
Each emoji is replaced with human readable string in the form
:name_of_emoji:
.
A character vector
example <- c( paste0("This is an emoji; ", emoji("person_facepalming")), paste0("You can write slides in ", emoji("key"), emoji("musical_note")) ) example emoji_replace_name(example)
example <- c( paste0("This is an emoji; ", emoji("person_facepalming")), paste0("You can write slides in ", emoji("key"), emoji("musical_note")) ) example emoji_replace_name(example)
This regex will capture all fully-qualified
and minimally-qualified
emojis.
emoji_rx
emoji_rx
character vector
https://www.unicode.org/reports/tr51/#emoji_data
Keep strings containing an emoji, or find positions
emoji_subset(string, negate = FALSE) emoji_which(string, negate = FALSE)
emoji_subset(string, negate = FALSE) emoji_which(string, negate = FALSE)
string |
input vector |
negate |
If |
A character vector
string <- c(letters[1:4], emoji_name[1:6]) emoji_subset(string) == emoji_name[1:6] emoji_subset(string, negate = TRUE) emoji_which(string) emoji_which(string, negate = TRUE)
string <- c(letters[1:4], emoji_name[1:6]) emoji_subset(string) == emoji_name[1:6] emoji_subset(string, negate = TRUE) emoji_which(string) emoji_which(string, negate = TRUE)
This data set is the heart of the emoji package. It contains various information regarding all the avaiable emojis as of v16.0.
emojis
emojis
tibble with 19 columns and nrow(emojis)
rows
character representation of the emoji
name
group, e.g. "Smileys & People"
sub group, e.g. "face-positive"
version where the emoji was introduced
Decimal Code Point(s)
number of runes the emoji uses
vector of unicode runes, i.e. hexadecimal representations prefixed with "U+"
Status of the emoji, can be one of 4 types; "component", "fully-qualified", "minimally-qualified", and "unqualified". See details for more.
logical indicating if the given vendor supports the emoji
vector of keywords
vector of aliases
The levels of qualified
have the following meaining
component: an Emoji_Component, excluding Regional_Indicators, ASCII, and non-Emoji.
fully-qualified: a fully-qualified emoji (see ED-18 in UTS #51), excluding Emoji_Component
minimally-qualified: a minimally-qualified emoji (see ED-18a in UTS #51)
unqualified: a unqualified emoji (See ED-19 in UTS #51)
Unicode® Full Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/full-emoji-list.html
Unicode® Emoji Charts v16.0 - https://www.unicode.org/emoji/charts-16.0/emoji-list.html
Unicode® Emoji Ordering, v16.0 - https://www.unicode.org/emoji/charts/emoji-ordering.txt
https://github.com/github/gemoji
https://github.com/muan/emojilib
emoji_name emoji_keyword
Insert Flag Emojis
flag(name, return_key = FALSE)
flag(name, return_key = FALSE)
name |
Character denoting the place of the flag. Set |
return_key |
Logical, set to TRUE to get full list of allowed names. |
This function is vectorized. The input is being normalized before matching
which will hopefully lead to lower friction and easier matching. Punctuation
is being removed and case is not taken into consideration when matching.
You can run flag(return_key = TRUE)
to get full list of allowed names.
Character vector of emojis.
flag(c("Vietnam", "Greenland", "Estonia", "Denmark", "united states")) flag(c("US Virgin Islands", "U.S. Virgin Islands", "u.s. virgin islands"))
flag(c("Vietnam", "Greenland", "Estonia", "Denmark", "united states")) flag(c("US Virgin Islands", "U.S. Virgin Islands", "u.s. virgin islands"))
Keycap emoji sequence
keycap(x)
keycap(x)
x |
character, must be a number between 0 and 10, "#", or "*". |
This function is vectorized.
a keycap version of x
keycap(6) keycap('#') keycap(1:10)
keycap(6) keycap('#') keycap(1:10)
Insert medal emojis
medal(place)
medal(place)
place |
Character denoting the place of the medal. See details for allowed names. |
This function is vectorized. There are a 1st, 2nd and 3rd place medals and allowed names are listed below. Note that matches are made without case.
1st place medal: "1", "1st", or "gold"
2nd place medal: "2", "2nd", or "silver"
3rd place medal: "3", "3rd", or "bronze"
Character vector of emojis.
medal(1:3) medal("gold") medal("Gold")
medal(1:3) medal("gold") medal("Gold")
Insert Moon Phase Emoji
moon(date, day = day_in_synodic_cycle(date))
moon(date, day = day_in_synodic_cycle(date))
date |
a date |
day |
number of days since new moon |
This function is vectorized.
If not supplied, day
is calculated using the
approximation of day_in_synodic_cycle, i.e the number of
days since a known new moon modulo 29.530588853
days.
a moon emoji
moon(Sys.Date()) january <- as.Date("2021-01-01") + 0:30 moon(january)
moon(Sys.Date()) january <- as.Date("2021-01-01") + 0:30 moon(january)
Insert Arrow emojis
shape(color, type)
shape(color, type)
color |
Character, denoting the color of the shape. Must be one of "red", "orange", "yellow", "green", "blue", "purple", "brown", "black", "white". |
type |
Character, denoting the type of shape. Must be one of "heart", "circle", or "square. |
This function is vectorized.
#@return Character vector of emojis.
shape("yellow", "heart") shape("yellow", c("heart", "circle", "square")) shape(color = c("red", "orange", "yellow", "green", "blue", "purple", "brown", "black", "white"), type = "circle") outer( c("red", "orange", "yellow", "green", "blue", "purple", "brown", "black", "white"), c("heart", "circle", "square"), shape )
shape("yellow", "heart") shape("yellow", c("heart", "circle", "square")) shape(color = c("red", "orange", "yellow", "green", "blue", "purple", "brown", "black", "white"), type = "circle") outer( c("red", "orange", "yellow", "green", "blue", "purple", "brown", "black", "white"), c("heart", "circle", "square"), shape )
This function returns random animals emojis.
zoo(size, replace = FALSE)
zoo(size, replace = FALSE)
size |
a non-negative integer giving the number of items to choose. |
replace |
should sampling be with replacement? Defaults to |
Character vector of animal emojis.
set.seed(1234) zoo(1) zoo(10)
set.seed(1234) zoo(1) zoo(10)