Visualize your Facebook friends network with R

January 19, 2012

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

A few days ago, Romain François explained how to interface with the Facebook Graph API explorer with R. This was a low-level interface, giving the R programmer the ability to the raw data that Facebook can provide about your connections. Now, just four days later, the first application in R (that I know of) based on the Facebook Graph API has been published.

 describes how to use R to visualize your Facebook friends as an interconnected graph. Petr uses Romain's facebook function to download the friends list via the API, and then constructs the friendship graph using the Rgraphviz package. To enhance the presentation, Petr goes one step further and downloads his friend's profile pictures (again, using the Facebook API and the download.file function), and uses the addlogo function (from the pixmap package) to decorate the nodes of the graph with faces. Here's the final result:


To find the R code to create a chart like this for your own Facebook friend network, follow the link to Petr's blog below.

Apply R: Mining Facebook Data: Most "Liked" Status and Friendship Network (via)

To leave a comment for the author, please follow the link and comment on his blog: Revolutions. 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.