lengthNonZeros: Calculate the species richness of a community

Description Usage Arguments Details Value References Examples

Description

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

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, Trisos and Farine.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(geiger)
library(picante)

#simulate tree with birth-death process
tree <- sim.bdtree(b=0.1, d=0, stop="taxa", n=50)

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

cdm <- simulateComm(tree, min.rich=10, max.rich=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/labAnalysis documentation built on May 16, 2019, 3:02 a.m.