Hi I am running species estimator calculations in the package 'vegan'.
The code I'm running is very simple:
library(vegan)
data(BCI)
p<-poolaccum(BCI, permutations = 50)
p.plot<-plot(p, display = c("chao", "jack1", "jack2"))
The object p.plot
is a trellis type object. So I was not able to convert it to a dataframe to for ggplot. The reason why I want to be able to use ggplot is because I want all the estimator curves to be on the same graph with labels. I'm also doing these plots for other datasets and I want to consolidate space as much as possible.
Any help would be great! Thank you
summary(p)
can help you get input data for ggplot2. I demonstrate Chao plot here:
library(ggplot2)
library(reshape2)
chao <- data.frame(summary(p)$chao,check.names = FALSE)
colnames(chao) <- c("N", "Chao", "lower2.5", "higher97.5", "std")
chao_melt <- melt(chao, id.vars = c("N","std"))
ggplot(data = chao_melt, aes(x = N, y = value, group = variable)) +
geom_line(aes(color = variable))
p
is what you got in p<-poolaccum(BCI, permutations = 50)
The output is like this, you can make some adjustment for multiple plots and theme.