R中的累积曲线 [英] accumulation curve in R
问题描述
我有几个月的时间在4个地点的物种数据.我已经在R中使用包vegan
成功创建了累积图,但是我想在一个图上绘制所有4个站点.
I have data of species at 4 sites over several months. I have successfully created accumulation graphs using package vegan
in R but I would like to plot all 4 sites on one graph.
起初,我有一个包含所有站点和月份的数据表,但是当我绘制specaccum
时,结果是一条曲线数据,所有数据都与站点无关.
At first I had a data sheet with all sites and months but the when I plotted specaccum
the result was a curve of accumulation of all data regardless of site.
因此,我将每个站点拆分为一个单独的数据表,然后将其加载到R中.在每个数据表中,第一行是物种名称,下面的每个其他行是一个月.
Because of this I split each site into a separate data sheet which I loaded into R. In each data sheet the first row is species names and each additional row below that is a month.
例如,我加载了我的网站"FMR"之一的数据.然后我做了以下事情:
For example I loaded the data of one of my sites "FMR". Then I did the following:
FMR <-specaccum(FMRJ2F, "random")
plot(FMR)
我对其他站点PP
,DUX
,PM
也做了相同的操作.如何将所有4条线放在一个图上?
I did the same for my other sites, PP
, DUX
, PM
. How can i put all 4 lines on one plot?
推荐答案
您可以在plot.specaccum(...)
library(vegan)
data(BCI)
df <- lapply(c(1,21,41,61,81),function(i)specaccum(BCI[,seq(i,i+19)], method="random"))
plot(df[[1]])
for (i in 2:5) plot(df[[i]],add=T, col=i)
此代码段仅将内置BSI数据集加载到vegan
中,并通过在BCI中的一部分列上运行specaccum(...)
来创建5 specaccum
对象的列表.因为您已经有了specaccum对象,所以您不需要这样做.
This code snippet just loads the built-in BSI dataset in vegan
, and creates a list of 5specaccum
objects by running specaccum(...)
on a subset of the columns in BCI. You don't need to to this since you already have the specaccum objects.
然后,我们创建第一个图,并用add=T
添加每条新曲线.
Then, we create the first plot, and add each new curve with add=T
.
这篇关于R中的累积曲线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!