hash_emoji {cli}R Documentation

Emoji hash

Description

Emoji hash

Usage

hash_emoji(x, size = 3)

Arguments

x

Character vector. NA entries will have an NA hash.

size

Number of emojis to use in a hash. Currently it has to be between 1 and 4.

Details

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.

Number of possible hash values

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

Value

A data frame with columns

See Also

the emoji package for a comprehensive list of emojis

Other hash functions: hash_animal(), hash_md5()

Examples

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

[Package cli version 3.1.0 Index]