How To Extract Tweets Using RStudio In 10 Simple Steps

Step 1Login with your Twitter login details.

Step 2: Go to https://apps.twitter.com and click on Create New App

Step 3: complete the mandatory fields with your ‘Name’, ‘Description’ and in ‘Website’ (https://www.excelr.com) and ‘call-back URL’ as blank 

Step 4: Check the option ‘Yes, I agree’ under Developer Agreement and Click on ‘your Twitter application’.

Step 5:Click on the Key and Access tokens’ section to find your Consumer key and Consumer Secret’ key

Step 6:Click on the Create My access token’ button and you can find your Access Token key and Access Token Secret keys

Step 7:Install all packages shown in below Image and run from lines 1 to 8 row

Step 8:Replace consumer Key with your Consumer key and consumer Secret and run the code from lines 10 to 14 & also run lines 16 & 17.

Step 09: In console, it will ask you to select option Yes or No, Press option 1 to proceed with authentication for Rdata.

Step 10: In console, it will ask you to select option Yes or No, Press option 1 to proceed with authentication for Rdata.

Run line 29 of the code by providing the Twitter account name of your area of interest in the single

quotes instead of ‘narendramodi’.

Line No 29 Tweetswill extract Narendramodi’s 1000 tweet. You can replace with any other person twitter profile name by changing in single quotes and “n” is value to extract no of tweets.

Now Run the code in lines  31 and 32 to create a CSV file of Modi’s tweets and to know the location of CVS file type “getwd()” which will show path of the CSV file as show in the below image.

Don’t forget to share this post,

Comment and get your doubts cleard!

Call Us