How to map your Twitter social network

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Ever wondered which Twitterers you and a friend share? Using R and the twitteR package, there’s an easy way to find out. Cornelius Puschmann hacked together some R code to do just that for the Humanities and Technology Camp and it seems to work pretty well. Just replace ‘coffee001’ with the your Twitter username, ‘mypassword’ with your Twitter password, and ‘Cornelius’ with your friend’s Twitter name, and the code does the rest. The only problem I had was that my graph was very cluttered, and despite the comments indicating you can set n to a smaller number, it didn’t work for me. (The code is very clearly commented, by the way.) I had to add the following two lines to make a readable chart:

friends.object <- friends.object[1:25]

followers.object <- followers.object[1:25]

The chart of followers I (@revodavid) share with the RevolutionR twitter account is below.


Although to be honest, looking at the chart now, I’m not actually sure this is our shared followers. I’ll have to look at the code more closely to figure out what’s going on; in any case it’s a neat example of integrating R with the Twitter API.

Cornelius Puschmann’s Blog: Code and brief instruction for graphing Twitter with R

To leave a comment for the author, please follow the link and comment on their blog: Revolutions. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)