Learn R Programming

phytools (version 0.7-20)

rstate: Pick a random state according to a vector of probabilities

Description

Primarily an internal function for make.simmap.

Usage

rstate(y)

Arguments

y

vector of probabilities. Must have names & should probably add to 1.0.

Value

A character or string.

Details

This function picks a random element in a vector according to the probability assigned that element. It returns the name. Uses rmultinom.

References

Revell, L. J. (2012) phytools: An R package for phylogenetic comparative biology (and other things). Methods Ecol. Evol., 3, 217-223.