Package Overview

tweetr is a R package for text analysis and sentiment analysis on tweets. The package will allow you to extract tweets from Twitter, visualize user habit on tweet posting, and apply sentiment analysis to the data.

Features

  • get_tweets:
    • This function extracts tweets from a Twitter user given their handle (i.e. @elonmusk).
    • Note that this function requires Twitter API credentials. Users need to store their credentials in a .Renviron file in the root directory.
  • plot_timeline:
    • This function creates an analysis of what time of day the tweets occurs and plots the counts of tweets and hours.
  • plot_hashtags:
    • This function creates an analysis of the hashtags in tweets, and plots the hashtag analysis.
  • sentiment_analysis:
    • This function applies sentiment analysis to tweets. It associates tokens in tweets with positive or negative sentiments and calculates their corresponding frequencies.
  • visualize_sentiment:
    • This function takes in the output of sentiment_analysis function and creates a visualization of user’s tweets with sentimental analysis.

Installation

You can install the released version of tweetr from CRAN with:

And the development version from GitHub with:

# install.packages("devtools")
devtools::install_github("UBC-MDS/tweetr")