Learn R Programming

twitteR

twitteR is an R package which provides access to the Twitter API. Most functionality of the API is supported, with a bias towards API calls that are more useful in data analysis as opposed to daily interaction.

Getting Started

  • Please read the user vignette, which admittedly can get a bit out of date
  • Create a Twitter application at http://dev.twitter.com. Make sure to give the app read, write and direct message authority.
  • Take note of the following values from the Twitter app page: "API key", "API secret", "Access token", and "Access token secret".
  • You can use the CRAN version (stable) via the standard install.packages("twitteR") or use the github version. To do the latter:
    • install.packages(c("devtools", "rjson", "bit64", "httr"))
    • Make sure to restart your R session at this point
    • library(devtools)
    • install_github("geoffjentry/twitteR")
  • At this point you should have twitteR installed and can proceed:
    • library(twitteR)
    • setup_twitter_oauth("API key", "API secret")
      • The API key and API secret are from the Twitter app page above. This will lead you through httr's OAuth authentication process. I recommend you look at the man page for Token in httr for an explanation of how it handles caching.
    • You should be ready to go!
  • If you have any questions or issues, check out the mailing list

Copy Link

Version

Install

install.packages('twitteR')

Monthly Downloads

1,211

Version

1.1.9

License

Artistic-2.0

Maintainer

Last Published

July 28th, 2015

Functions in twitteR (1.1.9)

retweets

Functions to work with retweets
taskStatus

A function to send a Twitter DM after completion of a task
timelines

Functions to view Twitter timelines
get_latest_tweet_id

A function to retrieve the most recent tweet ID from a database
search_twitter_and_store

A function to store searched tweets to a database
getTrends

Functions to view Twitter trends
register_db_backend

Functions to setup a database backend for twitteR
directMessage-class

Class "directMessage": A class to represent Twitter Direct Messages
getUser

Functions to manage Twitter users
twListToDF

A function to convert twitteR lists to data.frames
favorites

A function to get favorite tweets
getCurRateLimitInfo

A function to retrieve current rate limit information
setup_twitter_oauth

Sets up the OAuth credentials for a twitteR session
friendships

A function to detail relations between yourself & other users
strip_retweets

A function to remove retweets
searchTwitter

Search twitter
import_statuses

Functions to import twitteR objects from various sources
updateStatus

Functions to manipulate Twitter status
load_tweets_db

Functions to persist/load twitteR data to a database
dmGet

Functions to manipulate Twitter direct messages
showStatus

Functions to return statuses
user-class

A container object to model Twitter users
decode_short_url

A function to decode shortened URLs
status-class

Class to contain a Twitter status
registerTwitterOAuth

Register OAuth credentials to twitter R session
use_oauth_token

Sets up the OAuth credentials for a twitteR session from an existing Token object