accumulation curve in R

MyNameisTK picture MyNameisTK · Feb 6, 2014 · Viewed 12.4k times · Source

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.

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.

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.

For example I loaded the data of one of my sites "FMR". Then I did the following:

FMR <-specaccum(FMRJ2F, "random")
plot(FMR)

I did the same for my other sites, PP, DUX, PM. How can i put all 4 lines on one plot?

Answer

jlhoward picture jlhoward · Feb 7, 2014

You can just use the add=T argument in 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)

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.

Then, we create the first plot, and add each new curve with add=T.