Skip to contents

emoji_congruence() is emoji_incongruity() under the framing used in the marketing and eWOM literature, where the finding is that a mismatch between a review's words and its emoji lowers perceived helpfulness and authenticity. Same engine, same columns, plus .emoji_congruent.

Usage

emoji_congruence(
  data,
  text,
  text_score,
  method = c("difference", "sign_flip"),
  scale,
  where = c("all", "final"),
  threshold = 1,
  presentation = "emoji"
)

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() and dplyr::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 factor works and a numeric, Date or 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 carry U+FE0F.

text_score

Unquoted numeric column holding the text's own sentiment.

method

"difference" (default) for the continuous gap, or "sign_flip" for the categorical polarity-flip feature.

scale

How to make the two scores comparable: "rank", "zscore" or "none". Required – there is no sensible default. "rank" and "zscore" are computed over the rows carrying both an emoji score and a text_score, not over the whole corpus, so rows with no scorable emoji cannot shift the answer for the rows that have one.

where

"all" (default) scores every emoji in the row; "final" scores only the trailing run of emoji that ends the text.

threshold

For method = "difference", the absolute gap at or above which .emoji_incongruent is TRUE. Default 1, a full polarity swing on the rank scale. "sign_flip" has no gap to cut, so supplying both warns rather than letting half the call do nothing silently. A threshold at or below 0 flags every scored row, abs(gap) never being negative.

presentation

Which code points count as emoji: "emoji" (the default) or "any".

  • "emoji" requires emoji presentation, so U+2764 U+FE0F is an emoji and the bare U+2764 is 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 everything emoji_incongruity() adds plus .emoji_congruent, the negation of .emoji_incongruent.

Examples

df <- data.frame(
  text = c("lovely stay \U0001f600", "terrible room \U0001f600"),
  score = c(0.8, -0.9)
)
emoji_congruence(df, text, score, scale = "none")
#> # A tibble: 2 × 9
#>   text        score .emoji_n .emoji_n_scored .emoji_sentiment .emoji_incongruity
#>   <chr>       <dbl>    <int>           <int>            <dbl>              <dbl>
#> 1 lovely sta…   0.8        1               1            0.572             -0.228
#> 2 terrible r…  -0.9        1               1            0.572              1.47 
#> # ℹ 3 more variables: .emoji_polarity_flip <lgl>, .emoji_incongruent <lgl>,
#> #   .emoji_congruent <lgl>