data(finch.ind)
# \donttest{
#Define the functions that will be calculating
funct<-c("mean(x, na.rm = TRUE)", "kurtosis(x, na.rm = TRUE)",
"max(x, na.rm = TRUE) - min(x, na.rm = TRUE)" )
#Test against the null model regional.ind
res.finch.sp_regional.ind<-ComIndex(traits = traits.finch, index = funct, sp = sp.finch,
nullmodels = "regional.ind", ind.plot = ind.plot.finch,
nperm = 9, print = FALSE)
#Test against the null model regional.pop
#Individuals values are transformed in populational values
res.finch.sp_regional.pop<-ComIndex(traits = traits.finch, index = funct, sp = sp.finch,
nullmodels = "regional.pop", ind.plot = ind.plot.finch,
nperm = 9, print = FALSE)
#We can calculate index with or without intraspecific variance.
#With regional.pop, x holds one value per population, and ind.plot and sp
#give the plot and the species of each population.
funct.1<-c("tapply(x, ind.plot, function(x) mean(x, na.rm = TRUE))",
"tapply(x, ind.plot, function(x) kurtosis(x, na.rm = TRUE))",
"tapply(x, ind.plot, function(x) max(x, na.rm = TRUE)-min(x, na.rm = TRUE))",
"tapply(x, ind.plot, function(x) CVNND(x, na.rm = TRUE))" )
res.finch.withIV<-ComIndex(traits = traits.finch, index = funct.1,
sp = sp.finch, nullmodels = "regional.ind",
ind.plot = ind.plot.finch, nperm = 9, print = FALSE)
res.finch.withoutIV<-ComIndex(traits = traits.finch, index = funct.1,
sp = sp.finch, nullmodels = "regional.pop",
ind.plot = ind.plot.finch, nperm = 9, print = FALSE)
#ComIndex class are associated to S3 methods plot, print and summary.
res.finch.withIV
summary(res.finch.withIV)
plot(res.finch.withIV)
plot(res.finch.withoutIV)
plot(as.listofindex(list(res.finch.withIV, res.finch.withoutIV)))
# }
Run the code above in your browser using DataLab