emoji_risk() scores how likely each row's emoji are to be misread, using
the annotation-disagreement statistics of emoji_ambiguity(). It is the
content-QA counterpart of emoji_sentiment(): a row can carry a confident
positive score built entirely out of glyphs its annotators fought over.
Arguments
- data
A data frame or tibble containing a text column. Grouped data frames are accepted. The verbs that work a row at a time (adding columns, or keeping and expanding rows) carry the grouping through to their result, as
dplyr::mutate()anddplyr::filter()do. The verbs that pool across rows – the counts, the co-occurrence edge lists, the time series – warn that they ignore the grouping and return one corpus-wide answer.- text
The text column to scan, supplied unquoted. Any atomic column is accepted and read as character, so a
factorworks and a numeric,Dateor logical one simply contains no emoji. A list column – or a data-frame column – is refused rather than coerced, because coercing one deparses it and the emoji found would be in the code rather than in your data. What counts as an emoji is the same in every verb; see the Detection section of tidyEmoji for the one case that surprises people, code points that are emoji only when they carryU+FE0F.- measure
Ambiguity statistic to use; see
emoji_ambiguity().- threshold
Value at or above which a glyph counts as ambiguous.
NULL(default) uses the lexicon's upper quartile ofmeasure.- presentation
Which code points count as emoji:
"emoji"(the default) or"any"."emoji"requires emoji presentation, soU+2764 U+FE0Fis an emoji and the bareU+2764is not. This is the default and it will stay the default: widening it would silently recount every corpus already analysed."any"also reads the text-presentation spellings Unicode lists for an emoji (the bare heart,U+263A,U+2714, a keycap without its selector), because several keyboards emit them. It never reads the copyright, registered and trade-mark signs (U+00A9,U+00AE,U+2122), which are typography far more often than they are emoji.
"any"only ever adds occurrences: everything"emoji"finds, it finds too, in the same place.emoji_coverage()reports how many it adds and how many of those a lexicon can score, which is the cost of the choice in one number. Every verb that counts, scores or rewrites the emoji in a text column takes this argument, so counts still agree across the package for whichever value you use. The flag verbs do not need it, since a flag has no text-presentation form.
Value
data, as a tibble, with added columns .emoji_n,
.emoji_n_scored, .emoji_ambiguity_mean, .emoji_ambiguity_max and
.emoji_n_ambiguous. Rows with no emoji get NA throughout. A row that
has emoji the lexicon cannot score gets .emoji_n_scored = 0,
.emoji_n_ambiguous = 0 and NA for the two averages – there is nothing
to average, but the count of ambiguous glyphs found is genuinely zero.
Details
threshold decides what counts as an ambiguous glyph for
.emoji_n_ambiguous. The default, NULL, uses the upper quartile of the
chosen measure across the whole lexicon, i.e. "in the most-disputed quarter
of all emoji". Supply your own number to make the cut-off explicit in your
script.
Emoji absent from the lexicon cannot be scored and are excluded from the
means; .emoji_n and .emoji_n_scored together show how much of the row
was actually measured.
Examples
df <- data.frame(text = c("thanks \U0001f643", "great \U0001f600", "plain"))
emoji_risk(df, text)
#> # A tibble: 3 × 6
#> text .emoji_n .emoji_n_scored .emoji_ambiguity_mean .emoji_ambiguity_max
#> <chr> <int> <int> <dbl> <dbl>
#> 1 thanks 🙃 1 0 NA NA
#> 2 great 😀 1 1 0.835 0.835
#> 3 plain 0 NA NA NA
#> # ℹ 1 more variable: .emoji_n_ambiguous <int>