Sentiment Analysis in R
Ted Kwartler
Data Dude
library(qdap)
library(magrittr)
text_df %$% polarity(text)
Returns a "polarity" object with positive and negative scores.
A subjectivity lexicon is a predefined list of words associated with emotional context such as positive/negative, or specific emotions like "frustration" or "joy."
qdap
's polarity()
function uses a lexicon from hash_sentiment_huliu
tidytext
has a sentiments
tibble with
Name | Description |
---|---|
dodds_sentiment |
Mechanical Turk Sentiment Words |
hash_emoticons |
Translations of basic punctuation emoticons :) |
hash_sentiment_huliu |
U of IL @CHI Polarity (+/-) word research |
hash_sentiment_jockers |
A lexicon inherited from library(syuzhet) |
hash_sentiment_nrc |
5468 words crowdsourced scoring between -1 & 1 |
Rank | City | 2010 Census Population | Actual % | Zipf's Expected % |
---|---|---|---|---|
1 | New York | 8,175,133 | 100% | ... |
2 | LA | 3,792,621 | 46% | 50% |
3 | Chicago | 2,695,598 | 33% | 33% |
4 | Houston | 2,100,263 | 26% | 25% |
5 | Philadelphia | 1,526,006 | 19% | 20% |
If there are several ways of achieving the same goal, people will choose the least demanding course of action
Sentiment Analysis in R