Social Network Analysis with R

March 27, 2012

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

By Yanchang Zhao,

If you have tried social network analysis or graph mining with R, you might have already come across package igraph before. The package is designed for graphs and network analysis in R. It can handle large graphs very well and provides functions for interactive graph plotting and many other useful functions.

There is a tutorial on Network Analysis with package igraph by Gabor Csardi at Although the tutorial is still under development, it provides some useful R code examples on
– directed and undirected graphs;
– creating regular graphs, incl. full graphs, stars, rings, lattices and trees;
– creating graphs from real-world data;
– various random graphs;
– importing and exporting graphs in various formats, such as edge list files and Pajek format;
– Vertex and edge sequences and their indexing; and
– network flows and minumum cuts.

Below is a simple example picked up from the above tutorial. It creates a wheel graph and then draws a static plot and an interactive one with different layouts.
> library(igraph)
> g <- graph.union(graph.ring(9),, c=9, mode=”undirected”))
> plot(g, layout=layout.reingold.tilford)
> tkplot(g, layout=layout.kamada.kawai)

Another online resource on R for Social Network Analysis is available at

An online textbook on Introduction to social network methods can be
found at

More information on R and data mining is available at:
Group on Linkedin:
Group on Google:

To leave a comment for the author, please follow the link and comment on their blog: RDataMining. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, 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...


Comments are closed.

Search R-bloggers


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)