how to add specnames to rankabuncomp?

孤街浪徒 提交于 2019-12-12 06:08:59

问题


I am trying to add the species names to the rankabuncomp plot. I tried to add specnames = T to the rankabundance function but I get an error. Please help me work around this problem. Thanks a lot.

library(vegan)
library(BiodiversityR)
data(dune.env)
data(dune)
RankAbun.1 <- rankabundance(dune)
RankAbun.1
rankabunplot(RankAbun.1,scale='abundance', addit=FALSE, specnames=c(1,2,3))
rankabuncomp(dune, y=dune.env, factor='Management', scale='proportion',   legend=FALSE)
#to add specnames
rankabuncomp(dune, y=dune.env, factor='Management', specnames=c(1,2,3), scale='proportion', legend=FALSE, labels=FALSE)

回答1:


BiodiversityR::rankabuncomp explicitly disallows adding species names. This is hardcoded in the function and cannot be changed without editing the function (look for specnames = NULL in rankabunplot() calls). The help page does not give specnames argument to rankabuncomp so that this is also documented. I can understand this decision: rankabuncomp draws several lines in one graph, and often these are so similar that species names would overwrite each other and the plot becomes unreadable.

To add the lines, you either need edit the function or you must use a series of rankabunplot commands to overlay graphs in one plot. Here is an example how to do that with the dune data:

library(BiodiversityR)
data(dune, dune.env)
## list of models
mods <- with(dune.env, lapply(levels(Management), function(lev)
    rankabundance(dune, dune.env, 'Management', lev)))
## level 4 seems to be most extreme: draw it first 
rankabunplot(mods[[4]],scale='abundance', addit=FALSE, specnames=c(1,2,3))
## add the rest
## change colour etc to separate the lines if wished
rankabunplot(mods[[3]],scale='abundance', addit=TRUE, specnames=c(1,2,3))
rankabunplot(mods[[2]],scale='abundance', addit=TRUE, specnames=c(1,2,3))
rankabunplot(mods[[1]],scale='abundance', addit=TRUE, specnames=c(1,2,3))

The resulting plot is not very readable. If you use proportional scaling of y-axis, it becomes even less readable. However, you can do it.



来源:https://stackoverflow.com/questions/43859839/how-to-add-specnames-to-rankabuncomp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!