Now that we have the tweets down, it is useful to remove any unneccesary fluff: If you want to save these tweets for a later time, then use write.csv(downloadedData, "nameCSV.csv") to write the tweets to your hard drive. If you do not include retweets you will quite not get the amount of tweets you specified (as they are counted but not downloaded). # Put the tweets downloaded into a ameĬlinton_tweets <- twListToDF(clinton_tweets) Trump_tweets <- userTimeline(user = n = 200, includeRts = FALSE, retryOnRateLimit = 2000) This is a restriction of the Twitter Search API, and it often means you won't actually get the number of tweets you specified.Ĭlinton_tweets <- userTimeline(user = n = 200, includeRts = FALSE, retryOnRateLimit = 2000) Unfortunately you can't use the API to request tweets older than a week or two at most. We will use 200 in this example, but the maximum is 3200. # n specifies how many tweets you want from the user. To get warmed up, let’s see what the two US presidential nominees have been talking about.ĭownloading tweets from a single user is very easy, just use the userTimeline() Setup_twitter_oauth(API_key, API_secret, access_token, access_secret) # Type in your app details from Twitter here:
To get a feel for the commands we will pass through the code, I urge you to have a look at Twitter’s API documentation.
#Echofon for blackberry download code#
If you don’t have these packages, then use install.packages("NameOfPackage")īefore running the code above. I am going to use a combination of the excellent twitteR package and httr for pulling tweets,
#Echofon for blackberry download how to#
I’ll leave the details of how to get OAuth and dev-app running here, since it explains it better than I would have been able to.īy the end of this guide you will be able to download tweets from specific users and from lists, plotting commonly used words and examining tweeting activity using meta-data. This guide requires that you have a Twitter account, R(studio), and have setup a twitter-dev account with OAuth. Lastly, I wanted to show how analysing the Twitter meta-data in addition to the tweets themselves can lead to better behavioural insights. To this end, I will provide some simple functions built on top of other packages that enable you to download tweets from pre-specified groups of people instead of just whoever tweets on a certain topic. This approach also means that the scripts we want to write have to be more reusable in nature in order to retrieve, load, and analyze several different groups repeatedly. Meta-data can be a rich source of information for that. As researchers however, we are often also interested in comparing and contrasting data between groups. First, while there are many other guides on R-Bloggers that show similar things, they tend to focus more on setting up your Twitter account and using wordclouds.
I wanted to write this guide for several reasons. For my first blog post on R, I want to show how to use R to mine Twitter-data.