Theory, R functions & Examples
Section: Diversity analysis
specnumber (library vegan)- calculates species richness for individual samples, optionally number of species for different groups of samples. Applies on sample x species matrix of abundances, presences absences or other type of data (calculation of richness does not consider species abundances). Argument
groupallows to calculate group-based species richness (i.e. number of species occurring in samples classified into given group). Just a little more clever than simple
rowSums (x > 0).
diversity (library vegan)- calculates Shannon and Simpson index. Applies on the sample x species matrix, where cells are species abundances. Argument
shannon(calculates Shannon entropy),
simpson(calculates Gini-Simpson index, i.e. 1-Simpson, since Simpson index decreases with richness), and
invsimpson(calculates reciprocal Simpson 1/D, which in fact is Simpson diversity - effective number of species calculated from Simpson's concentration index). Argument
basecan modify the base of the logarithm which is used to calculate Shannon (default is natural logarithm, some prefer to use base = 2). The function works also if data are not genuine counts of individuals (abundances), but other measures (dominance, cover); in that case, the interpretation is not “randomly chosen individual” (Shannon) or “two randomly chosen individuals” (Simpson), but e.g. “randomly chosen bit's of biomass”.
d (library vegetarian)- calculates Hill numbers for alpha, beta and gamma diversity. Applies on sample x species matrix of abundances (or biomass, cover etc.). Argument
qmodifies the coefficient q of the Hill numbers; default is
q = 1, which is Shannon diversity (effective number of species calculated from Shannon's entropy).
qcan be any real number (also negative, although that makes not sense since this would give high weight to rare species). Allows to estimate confidence intervals via bootstrapping. For
level = 'alpha' it calculates diversity on the level of individual rows (samples), for
level = 'gamma' on the level of the whole dataset.
level = 'beta' calculates beta richness.