Below is a bonus coding example using twitter data

library(twitteR)
library(tidytext)
library(tidyverse)
knitr::opts_chunk$set(message = FALSE, warning = FALSE)
setup_twitter_oauth(consumer_key, consumer_secret, access_token, access_secret)
## [1] "Using direct authentication"

Sentiment analysis on tweets containing “Happy Holiday”

sc_twitter <- searchTwitter("Soleimani",n=1000,lang="en",resultType = "popular")
sc_twitter_df <- twListToDF(sc_twitter) # Convert to data frame


tweet_words <- sc_twitter_df %>% select(id,screenName,retweetCount,isRetweet,favoriteCount, text) %>% unnest_tokens(word,text)

num_lex <- get_sentiments("afinn")

tweets<-tweet_words%>%
  left_join(num_lex)%>%
  group_by(id,screenName)%>%
  summarize(lh=sum(value,na.rm=T))

tweets_df<-left_join(sc_twitter_df,tweets,by=c("id","screenName"))%>%filter(retweetCount>0)

ggplot(tweets_df,aes(created,lh,col=favoriteCount))+
  geom_point()+
  geom_smooth()+
  scale_y_continuous(limits = c(-5, 5))+
  labs(title="Scatter plot of sentiment of tweets",x="Time tweeted",y="Sentiment score")

ggplot(tweets_df,aes(lh))+
  geom_density()+
  scale_x_continuous(limits = c(-6, 6))+
  labs(title="Density of sentiment of tweets",x="Sentiment score",y="Density")