How to analyse Twitter connections using R

Twitter is an amazing microblogging tool and an extraordinary communication medium. In addition, Twitter can also be used for text and social web analysis. There are many software that can be used to analyse Twitter but R offers a wide variety of options to do lots of interesting and fun things to analyse the Twitter. So, let see how to perform Twitter’s big data analytics with R.

Twitter Analysis:

Creating a Twitter Application

  1. The first step to perform Twitter analysis is to create a Twitter Application. With the help of this application, we can perform analysis by connecting R console to the Twitter using Twitter API.
  • Go to http://dev.twitter.com and login by using your Twitter account.
  • Then go to Manage your Apps -> Create a new application.


Type your application name, describe about your application in few words, and provide your website URL. Complete other formalities and create your Twitter application. Once all the steps are done, accept the agreement. Then, the created application will display.


Next, I will work on my RStudio and use the consumer key, secret key, Access key, etc. to access the Twitter.

Working in RStudio

1.     Install R packages

The first step is to install some packages in R. These are twitteR, RCurl and igraph.

2.Set SSL certificate globally 




3.     Accessing the Twitter API
Now, we are going to access the twitteR API by giving below code.


4.     Accessing the Followers and Friends Information

Once the authentication is completed and authorized by Twitter, we can fetch followers and friends IDs and its name by using the user name of Twitter account.



5.  Make a relation of user to friends and Followers. 


6.     Plot the Network graph


Now, we are going to plot the network graph by using following code.



So, this is the procedure to build a network connections to the Twitter using R. Using Twitter with R predictive analytics, you can not only make network graph, but can also fetch tweets and perform sentiment Analysis on it. 
Previous
Next Post »

Popular Posts