Learn R Programming

analogue (version 0.17-7)

n2: Calculate Hill's N2 diversity measure

Description

Hills N2 is a measure of species diversity, commonly referred to as "effective" diversity. If computed on the rows (samples) then the "effective" number of species in each row is returned, whereas, if computed on the columns (species) then the "effective" number of occurences of each species in the data set is returned.

Usage

n2(x, ...)

# S3 method for default n2(x, which = c("species", "sites"), ...)

Value

A numeric vector of N2 values.

Arguments

x

matrix or data frame of species data

which

character; compute N2 on the rows ("sites") or the columns ("species") of x

...

arguments passed to other methods

Author

Gavin L. Simpson

Examples

Run this code
data(swapdiat)
sppN2 <- n2(swapdiat, "species")
head(sppN2)
sampN2 <- n2(swapdiat, "sites")
head(sampN2)

Run the code above in your browser using DataLab