Performing a Twitter sentiment analysis
Twitter sentiment analysis is another powerful tool in the text analytics toolbox.
With sentiment analysis, we can analyze the mood expressed within a text.
In this recipe, we will download tweets relating to "data science with R" and perform a sentiment analysis on them, employing the bag of word technique.
The main feature of this technique is not trying to understand the meaning of the analyzed text but just looking at one word at the time, seeing whether it expresses a positive or negative sentiment.
Our example will therefore result in computing the overall sentiment around the topic, algebraically summing up the sentiment score of every single word in our bag.
Getting ready
This recipe will leverage powerful functions from three different packages: one for downloading tweets, one for string manipulation, and the last one for text analytics activities.
We therefore need to install and load those packages:
install.packages(c("twitteR","stringr","tm")...