Emoji co-occurrence counts, with an optional diagonal
Source:R/emoji-relate.R
emoji_cooccurrence.Rdemoji_cooccurrence() is emoji_pairs() under another name, with one
addition: diagonal = TRUE also returns the item1 == item2 rows, whose
n is the number of documents containing that emoji (the diagonal of the
co-occurrence matrix, i.e. its document frequency).
Arguments
- data
A data frame or tibble containing a text column.
- text
The text column to scan, supplied unquoted.
- doc_id
Optional unquoted column identifying documents. Rows sharing a value are treated as one document. Default: each row is a document.
- diagonal
If
TRUE, include oneitem1 == item2row per emoji with its document frequency. DefaultFALSE.- sort
If
TRUE(default), sort by descendingn(ties broken byitem1,item2so the order is deterministic).
Examples
df <- data.frame(text = c("\U0001f602\U0001f60d", "\U0001f602"))
emoji_cooccurrence(df, text, diagonal = TRUE)
#> # A tibble: 3 × 3
#> item1 item2 n
#> <chr> <chr> <int>
#> 1 😂 😂 2
#> 2 😂 😍 1
#> 3 😍 😍 1