Skip to content

Instantly share code, notes, and snippets.

@monogenea
Created October 7, 2019 16:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save monogenea/d1642e14052199f9b0987d226fb126bb to your computer and use it in GitHub Desktop.
Save monogenea/d1642e14052199f9b0987d226fb126bb to your computer and use it in GitHub Desktop.
# Sentiment analysis
tknDct <- tokens_lookup(tkn, dictionary = data_dictionary_LSD2015)
saDfm <- dfm(tknDct,
remove = stopwords("en"),
stem = T)
summ <- do.call("rbind", by(convert(saDfm, to="data.frame")[,-1],
INDICES = date(tweetReduced$created_at),
FUN = colSums))
dev.off() # reset past graphical pars
plot(date(rownames(summ)),
(summ[,2] - summ[,1]) / rowSums(summ[,1:2]),
type = "l", xlab = "Date", ylab = "Sentiment score")
abline(h = 0)
abline(v = date(epAirTime), lty = 2, col = rgb(1,0,0,.5))
text(date(epAirTime) - 3, .095, labels = paste0("Ep.", c(1:6)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment