retweets twitter with R

Visualize Retweets with R

Hi there!

Today I want to show you how to plot a graph filled with Data of Retweets of a Twitter Account.

To start you have to go through the Twitter authentification process as i described in an earlier blog post you can find here.

Let´s get started with the things we are really interested in.

Get the data

To start the data mining we need to load 3 packages.

To get the posts of a certain user, the twitteR package provides a cool function

This gets us around 1000 tweets from the user account @mashable. These are saved in the Variable tweets and we can extract the text in the next step with

But now we have to recognize the retweets in this huge amount of text.

Now that we have our raw data we can go on analyzing it.

Visualize Retweets with R

 

Now we have created our so called edge list. A list which shows the connections of our data. A very common construct in R.
But our goal wasn´t an edge list, but a graph. So we have to form our edge list in a nice graph.

Now there are just a few steps left to see our retweet graph.

And here it is:

Our nice retweets graph!

retweets mashable

Julian Hillebrand

During my time at university and learning about the basics of economics I started heavily exploring the possibilities and changes caused by digital disruptions and the process of digital transformation, whereby I focused on the importance of data and data analytics and combination with marketing and management.
My personal focus of interest lies heavily on technology, digital marketing and data analytics. I made early acquaintance with programming and digital technology and never stop being interested in following the newest innovations.

I am an open, communicative and curious person. I enjoy writing, blogging and speaking about technology.