Drawing a trophic network (part 2)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Following discussion on the comments of the previous post, I thought about how it was possible to draw links going in several directions (i.e. there are no ‘clear’ differences between the levels, and species from level n can interact with species of level n, n+1, n-1, n±k, etc).
This is now done, with a code that is as inelegant as humanly possible. Also, the way to lay the different nodes on the graph (i.e. their ‘trophic level’) should be calculated with a proper method, but (i) I am not a specialist of these metrics, and (ii) it is way too late to do any decent bibliographical research to look them up.
The procedure I use here is quite horrible. I randomly reorder the matrix, and compute the trophic position by elevating each species whenever it eats another species. I repeat this a couple time, and then average the trophic position for each species. The x position is a simple random value, which means that you will probably need to do the launch the code a couple times to get a decent looking network.
The R code can be downloaded here.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.