Learn R Programming

vegan (version 1.4-0)

diversity: Ecological Diversity Indices

Description

Shannon and Simpson diversity indices for community ecologists.

Usage

diversity(x, index="shannon", MARGIN=1, base=exp(1))

Arguments

x
Community data matrix.
index
Diversity index, one of shannon, simpson or invsimpson.
MARGIN
Margin for which the index is computed.
base
The logarithm base used in shannon.

Value

  • Vector of diversity indices.

Details

Shannon or Shannon--Weaver (or Shannon--Wiener) index is defined as $H' = -\sum_i p_i \log_{b} p_i$, where $p_i$ is the proportional abundance of species $i$ and $b$ is the base of the logarithm. It is most popular to use natural logarithms, but some argue for base $b = 2$ (which makes sense, but no difference).

Both variants of Simpson's index are based on $S = \sum p_i^2$. Choice simpson returns $1-S$ and invsimpson returns $1/S$.

Examples

Run this code
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