This is the basic example given in the iNEXT package:
library(iNEXT)
data(spider)
# multiple abundance-based data with multiple order q
z <- iNEXT(spider, q=c(0,1,2), datatype="abundance")
p1 <- ggiNEXT(z, facet.var="site", color.var="order")
In my dataset, i have more samples and the facetting does not work so great:
, so i want to change the ncol/nrow arguments in the facet_wrap/grid-call inside the object "p1". p1 is a ggplot object, so it can be altered (f.e. p1 + xlab("")
removes the x-title).
In general, it would be nice to know how gginext()
can be decomposed into single lines, and what objects are used in the data arguments, so i can change the order of the samples and reduce the amount of samples used per plot. Somehow, i wasnt able to find that out by looking at the function itself, also i get "Error: ggplot2 doesn't know how to deal with data of class iNEXT" when i try to follow gginext()
step-by-step.
You could use facet_wrap(~site, ncol=3)
to tune your plot. Take a simple example as following:
library(iNEXT)
library(ggplot2)
set.seed(123)
p <- 1/1:sample(1:50, 1)
p <- p/sum(p)
dat <- as.data.frame(rmultinom(9, 200, p))
z <- iNEXT(dat, q=c(0,1,2))
p1 <- ggiNEXT(z, facet.var="site", color.var="order")
p1 + facet_wrap(~site, ncol=3)