Data Analytics

Twitter Sentiment Analysis (February 2018)

Sentiment Analysis is the process of ‘computationally’ determining whether a piece of writing is positive, negative or neutral. It’s also known as opinion mining, deriving the opinion or attitude of a speaker.

More information on sentiment analysis


Data can be easily collected from Twitter by selecting Twitter Search menu from Remote Data dialog. This is using Twitter Search API through the TwitteR package to get the tweet data based on the search query.  There are some limitations in the API of Twitter.  Typically, you are limited to  tweets for the last 7-8 days.

The R Syuzhet package.  comes with four alternative sentiment dictionaries and provides a convenient method for accessing the robust, but computationally expensive, sentiment extraction tool developed in the NLP group at Stanford University.  Since these alternative measures are scaled differently, I transformed all of the outcomes to the 0-1 range for comparison purposes.   Negative sentiment would be towards zero, while values approaching 1 would be positive.

Many tweets have a location reference (geocode) that allows for some analysis of regional or site specific differences in sentiment.  For example, the analysis of sentiment about U.S. agriculture shows different patterns over the last week between the Midwest region and West region.