How to map your Twitter social network

May 26, 2010
By

(This article was first published on Revolutions, and kindly contributed to R-bloggers)

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.

Twittermap

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 his blog: Revolutions.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...



If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Tags: ,

Comments are closed.