Analysing Google Plus posts using R language #rstats

Here is a short post in retrieving information from the Google+ API using R, and then analysing it.

To create an API key:

  1. Go to the Google Developers Console.
  2. Create or select a project.
  3. In the sidebar on the left, select APIs & auth.
  4. In the displayed list of APIs, find the Google+ API and set its status to ON.
  5. In the sidebar on the left, select Credentials.
  6. Create an API key by clicking Create New Key. Select the appropriate kind of key: Server key  Then clickCreate.

from- https://developers.google.com/+/api/oauth

and the R code

#install.packages("plusser")
library(plusser)
help(plusser)
library(RCurl)
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
setAPIkey('AIzaSyBtYqDsAtzp4FOS7FGbrc_n6mD-uJIOvcQ')
myProfile=harvestProfile("+AjayOhri", parseFun = parseProfile)
str(myProfile)
myposts=harvestPage("+AjayOhri", parseFun = parsePost, results = 1, nextToken = NULL, cr = 1)
str(myposts)
head(myposts)
plot(myposts$ti,myposts$nC) #number of comments
plot(myposts$ti,myposts$nP) #number of likes or plus 1
plot(myposts$ti,myposts$nR) #number of reshares

some screenshots and images Screenshot 2014-06-26 13.33.08

Screenshot 2014-06-26 13.32.56

You can also see the Rpubs document here http://rpubs.com/decisionstats2/plusser Now you can do text analysis and sentiment analysis on myposts$msg and do social media analysis on what makes people like what kind of content. 


For better results, use a google plus id (page or person) which has a lot of PUBLIC posts!

 

Author: Ajay Ohri

http://about.me/ajayohri

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: