Learn more about using open source R for big data analysis, predictive modeling, data science and more from the staff of Revolution Analytics.

January 19, 2012

Visualize your Facebook friends network with R

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.

Petr Simecek 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.