Analyzing Twitter data with R (part 1: connecting to Twitter API )

Mar 17, 2015

Analyzing Twitter data with R (part 1: connecting to Twitter API )



All "Smart" Businesses are looking to understand the social media trends , to analyze the massive amount of public data available online and to make insightful decisions based on these analysis.


Source :http://www.slashgear.com/twitter-data-grants-introduced-to-offer-select-institutes-data-trove-05315867/


For any statistician or future data scientist freshly graduating out of the university, it is very important to be able to have certain skills with the statistical modeling and mathematical knowledge.

In this series of posts, I will detail the necessary steps for that you will need to access Twitter, import data, clean it and analyze it and have a conclusion based on the data you have extracted.

It will be a simple step-by-step tutorial if you'd like to call it that way.

This series of posts is destined to students, currently taking data science classes, and to anyone interested in R language and social media in particular .

I've been asked to make the same thing with Python also. I will try to make time and share some Python practices for those using it for data analysis. But I encourage you to learn R !




Let's start! 



The way Twitter allows users to connect to its API  is to have an authentication parameters that gives developers access to its database.

To have you access parameters, you need to have a Twitter account.





Login to you account and go to  https://apps.Twitter.com. You will find a create a new application button and click that:



Name : give you application any name you'd like to give. Keep it fun! Twitter limits the name to 32 characters length.

Description : it's required that you give a quick description for your application. It is useful when you have many applications and you can not re-call what does this application do exactly.

Website : The Twitter descriptive text is very clear, if your have a website where your work/application can be available , put it. Otherwise, just put a placeholder, your github site or your blog address.

Callback URL: at your level now, you do not need to put any callback URLs, so skip that part.




Now if you have some time, you can read the stuff in the Developer Agreement. But like most of us (99.99%) we will agree because we are going to use the service anyways. 



And Bam! Now you have your application ready!




The next step is to go to the application management interface and get the Keys and Access Tokens we will need to the second part of your work:








Now all you need to do is to copy/paste these keys to a file and get to your Rstudio, because in the next part we will use these keys to access the Twitter data!


PART 2 HERE !