Twitter - R integration and extract data between from and till date

Here is complete end to end integration walk through for twitter and R. It will help the data retrieval between two dates "since and until"

PreRequisite:

  1. Twitter Account
  2. R

Steps:

Step 1: Go to https://apps.twitter.com/app/

Step 2: Sign-in to your twitter account

Step 3: Click on create new app

 

Step 4: Fill basic requirement to create app credential

 

Step 5: After clicking on create twitter application, it will generate consumer key and secret. This will be required while writing the R script.

 

Step 6: Create access token. It will be used in coding

Once you'll click on create access token it will generate access token and access secret. Copy the access token and secret for further use.

 

Now your connection application is ready.

Let's start the R portion

Run below code in your R/RStudio platform

The above code will authorize your R and application integration.

Now to retrieve data from twitter and analysis in R follow the below instruction. An example of simple wordcloud is taken for tweets tagged to RCBTweets (Royal Challenger Bengaluru official twitter handler). It is taken between the date since=2017-03-24 , until=2017-03-31.

Output: "WordCloud"

 

Note: There are so many parameter can be passed to restrict the tweets in "searchTwitter" function, such as locale, sinceID, maxID, geolocation etc.

 

Hope the article will help you in integration between R and Twitter.

 

 

 

 

Leave a Comment