Skip to content

Instantly share code, notes, and snippets.

@aloth
Created July 24, 2017 10:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aloth/76a9de44c3fed013d2332e51571bfc3d to your computer and use it in GitHub Desktop.
Save aloth/76a9de44c3fed013d2332e51571bfc3d to your computer and use it in GitHub Desktop.
Fetching tweets with R (sample for TC17)
library(twitteR)
library(ROAuth)
## Twitter authentication
## Replace strings with your credentials
setup_twitter_oauth("consumer_key", "consumer_secret",
"access_token", "access_secret")
# Fetch tweets from user timeline
tweets <- userTimeline("xlth", n = 3200)
# Convert tweets to a data frame
tweets.df <- twListToDF(tweets)
# Wrtite CSV file with tweets
write.csv(tweets.df, file="tweets.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment