Sentiment Analysis of Twitter Data

CRAN_Status_Badge R-CMD-check codecov Downloads Total Downloads GitHub last commit status DOI


This package is focused on utilizing Twitter data due to its widespread global acceptance. The rapid expansion and acceptance of social media has opened doors into opinions and perceptions that were never as accessible as they are with today’s prevalence of mobile technology. Harvested Twitter data, analyzed for opinions and sentiment can provide powerful insight into a population. This insight can assist companies by letting them better understand their target population. The knowledge gained can also enable governments to better understand a population so they can make more informed decisions for that population. During the course of this research, data was acquired through the Public Twitter Application Programming Interface (API), to obtain Tweets as the foundation of data and will build a methodology utilizing a topic modeling and lexicographical approach to analyze the sentiment and opinions of text in English to determine a general sentiment such as positive or negative. The more people express themselves on social media, this application can be use1`d to gauge the general feeling of people.


The saotd package is an R interface to the Twitter API and can be used to acquire Tweets based on user selected #hashtags and was developed utilizing a tidyverse approach. The package was designed to allow a user to conduct a complete analysis with the contained functions. The package will clean and tidy the Twitter data, determine the latent topics within the Tweets utilizing Latent Dirichlet Allocation (LDA), determine a sentiment score using the Bing lexicon dictionary and output visualizations.


You can install the CRAN version using:


You can install the development version from GitHub using:

devtools::install_github('evan-l-munson/saotd', build_vignettes = TRUE)

Using saotd

The functions that are provided by saotd are broken down into five different categories: Acquire, Explore, Topic Analysis, Sentiment Calculation, and Visualizations.


For an example of how to use this package, find the vignette at:




Getting help

If you encounter a clear bug, please file a minimal reproducible example on github.


If you would like to contribute, please create a Pull Request and make appropriate applicable changes for review.