Last chance! 50% off unlimited learning
Sale ends in
diversity(x, index="shannon", MARGIN=1, base=exp(1))
shannon
, simpson
or
invsimpson
.base
used in shannon
. Both variants of Simpson's index are based on $S = \sum p_i^2$. Choice simpson
returns $1-S$ and
invsimpson
returns $1/S$.
data(varespec)
H <- diversity(varespec)
## Species richness (S) and Pielou's evenness (J):
S <- apply(varespec>0, 1, sum)
J <- H/log(S)
Run the code above in your browser using DataLab