Analyze Google+ Posts with R [Update]

Share on FacebookTweet about this on TwitterShare on Google+Share on RedditShare on LinkedInEmail this to someone

Analyze google+ posts with R

Hey everybody,

today I show you how you can start working with the Google+ API to analyze Google+ posts with R. We create a personal API key, get our own stats and plot them in a nice looking graph.

Get the API Key

You can get our API key on the Google Developer console here: https://code.google.com/apis/console

There you can see an overview of you API activities if you have some. To create a new API connection click on “APIs” and turn on the Google+ API.

Google API Console API

Google API console API menu

After you did this, you can click on “Google+” and you see a list of the available API calls. Now click on “Credentials” on the left and click on “Create new key” to create a new public API access. Then click on “Browser key” and then “Create”.

Google API calls

Google API credentials

Google API accessGoogle API key

And there it is: you API key.

Analyze Google+ Posts with R

For our first analysis we need the packages

 

 

And we need our api key and our user id:

 

 

In this case I used my own Google+ ID but you can use every ID you want. But we can just receive the public posts.

We get our raw data and put it in a JSON object with:

 

 

We can now put the data in a DataFrame to make it more readable. But we don´t need all the values we received as these are a lot. We get the fields

df

 

We can save this DataFrame as a CSV file with:


 

Visualize your Posts

To visualize your posts we extract the informations we need and store them in the Data Frame df_graph

Then we can plot it with

 

Bildschirmfoto 2013-12-28 um 19.43.45

You can find the complete code on my github page here.

Please follow me on Twitter to stay up to date.

Share on FacebookTweet about this on TwitterShare on Google+Share on RedditShare on LinkedInEmail this to someone

JulianHi

I´m an International Business student from Germany, interested in Data Analytics and Machine Learning with a focus on Marketing Applications. My favorite language is R.

You may also like...

6 Responses

  1. So, why would we want to do this? What does R bring to scatterplots of Google+ accesses?

    • julianhi says:

      Hey hypergeometric,
      thanks for your comment.
      My purpose of this post was on the one hand to show again the possibilities of R as something more than “just” a statistical language. With all its packages R got a lot of more different layers.
      And on the other hand to show some of the possibilities of the Google+ API, which is not as developed as the Facebook API but also has some cool functions.
      And to bring these two aspects together I wrote this post.
      And you should do this when you are interested in your posts performance on Google+. This is more about Social Monitoring than about statistical computing.
      I hope I could help you.
      Regards

  2. Demas says:

    Hi, it is really good, thanks for sharing!

    Also, I’d like to know if is possible to do something like they did for twitter using TwitterR (https://sites.google.com/site/miningtwitter/mining-viz).

    Best,
    Demetrius.

    • julianhi says:

      Hey Demas,
      there are a lot of possibilites of working with Google+. This is a very interesting topic and I will write some new tutorials when I have some time. So follow my blog and you get noticed when there are new tutorials available.

      Regards

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">