lengthNonZeros: Calculate the species richness of a vector from a CDM

Description Usage Arguments Details Value References Examples

View source: R/lengthNonZeros.R

Description

Given a vector of abundances or presence/absences from a community data matrix, will calculate the species richness of that vector.

Usage

1
lengthNonZeros(input.vector)

Arguments

input.vector

A vector from a community data matrix of abundances.

Details

An internal function to calculate richness of a cdm.

Value

A named vector of species richness.

References

Miller, E. T., D. R. Farine, and C. H. Trisos. 2016. Phylogenetic community structure metrics and null models: a review with new methods and software. Ecography DOI: 10.1111/ecog.02070

Examples

1
2
3
4
5
6
7
8
9
#simulate tree with birth-death process
tree <- geiger::sim.bdtree(b=0.1, d=0, stop="taxa", n=50)

sim.abundances <- round(rlnorm(5000, meanlog=2, sdlog=1)) + 1

cdm <- simulateComm(tree, richness.vector=10:25, abundances=sim.abundances)

#note that with this example, each community in the cdm will be labeled by its richness
apply(cdm, 1, lengthNonZeros)

eliotmiller/metricTester documentation built on Dec. 16, 2019, 12:39 p.m.