# Viewing a bipartite network

July 30, 2010
By

(This article was first published on Timothée Poisot » R, and kindly contributed to R-bloggers)

I published two functions to visualize trophic networks with three or n levels, although most of my work consists in dealing with two-mode (bipartite) networks. The R library bipartite provides two functions to visualize such webs (plotweb and visweb), and I am generally happy with the results of the latter. However, I sometimes find it difficult to use at it seems to require link intensity to be given as integers, and I never have this information. Even if it is easy to do something like

web <- round(web,3)*1e3

it is not really satisfactory.

There are also some other minor things with the bipartite package (namely, it requires the matrix to be entered « the wrong way », i.e. with the columns where one should expect to find the rows) and the graphical output of this particular function that make me uncomfortable using it.

I wrote a very short piece of R code that uses lines from the original function (to be exhaustive : the calculation of the margin size, and the sorting of the matrix to give it an ecological meaning), and obtained the following output quite easily:

I quite like the look of this, and I think that it is really easier to follow who interacts with who by just « sliding » along the grey lines.

You can get the R code here.

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