Get specific sentiment lexicons in a tidy format, with one row per word,
in a form that can be joined with a one-word-per-row dataset.
Each of these comes from the included sentiments data frame,
but this performs the filtering for a specific lexicon, and removes
columns that are not used in that lexicon.
get_sentiments(lexicon = c("afinn", "bing", "nrc", "loughran"))
| lexicon | The sentiment lexicon to retrieve; either "afinn", "bing", "nrc", or "loughran" |
|---|
A tbl_df with a word column, and either a sentiment
column (if lexicon is not "afinn") or a numeric score column
(if lexicon is "afinn").
library(dplyr) get_sentiments("afinn")#> # A tibble: 2,476 x 2 #> word score #> <chr> <int> #> 1 abandon -2 #> 2 abandoned -2 #> 3 abandons -2 #> 4 abducted -2 #> 5 abduction -2 #> 6 abductions -2 #> 7 abhor -3 #> 8 abhorred -3 #> 9 abhorrent -3 #> 10 abhors -3 #> # ... with 2,466 more rowsget_sentiments("bing")#> # A tibble: 6,788 x 2 #> word sentiment #> <chr> <chr> #> 1 2-faced negative #> 2 2-faces negative #> 3 a+ positive #> 4 abnormal negative #> 5 abolish negative #> 6 abominable negative #> 7 abominably negative #> 8 abominate negative #> 9 abomination negative #> 10 abort negative #> # ... with 6,778 more rows