hash_emoji | R Documentation |
Emoji hash
hash_emoji(x, size = 3)
hash_raw_emoji(x, size = 3)
hash_obj_emoji(x, size = 3, serialize_version = 2)
x |
Character vector. |
size |
Number of emojis to use in a hash. Currently it has to be from 1 through 4. |
serialize_version |
Workspace format version to use, see
|
It uses the first 13 hexadecimal characters (out of the 32) of the MD5 hash of the input, and converts them into an emoji representation. It uses a manually selected subset of all emojis, that tend to be displayed correctly.
cli uses 2280 possible emojis. This is the number of
different hashes you can get for different values of size
:
size | size of hash table space |
1 | 2,280 |
2 | 5,198,400 |
3 | 11,852,352,000 |
4 | 27,023,362,560,000 |
hash_raw_emoji()
calculates the emoji hash of the bytes
of a raw vector.
hash_obj_emoji()
calculates the emoji hash of an R
object. The object is serialized into a binary vector first.
hash_emoji()
returns a data frame with columns
hash
: the emoji hash, a string of the requested size.
emojis
: list column with the emoji characters in character
vectors. Note that an emoji might have multiple code points.
text
: text representation of hash
, comma separated.
names
: list column with the text representations of emojis
, in
character vectors.
hash_raw_emoji()
and hash_obj_emoji()
return a list with
entries:
hash
: the emoji hash, a string of requested size,
emojis
: the individual emoji characters in a character vector,
text
: text representation of hash
, comma separated,
names
: names of the emojis, in a character vector.
the emoji package for a comprehensive list of emojis
Other hash functions:
hash_animal()
,
hash_md5()
,
hash_sha1()
,
hash_sha256()
hash_emoji(c("foo", NA, "bar", ""))$text
# if you increase `size`, the shorter hash is a prefix of the longer:
hash_emoji("foobar", 1)$text
hash_emoji("foobar", 2)$text
hash_emoji("foobar", 3)$text
hash_emoji("foobar", 4)$text
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.