ApplyByClass {cheddar} | R Documentation |
Apply by class
Description
Apply functions to a group of values given by a node property.
Usage
ApplyByClass(community, property, class, fn, ...)
SumMByClass(community, class, na.rm=FALSE)
SumNByClass(community, class, na.rm=FALSE)
SumBiomassByClass(community, class, na.rm=FALSE)
Arguments
community |
an object of class |
property |
the property to which |
class |
the property over which |
fn |
a function. |
na.rm |
logical - if |
... |
Other parameters to |
Details
ApplyByClass
applies fn
to property
by class.
property
and class
should both be names that meet the criteria
of the properties
argument of NPS
.
SumMByClass
, SumNByClass
and SumBiomassByClass
are
convenient wrapper around ApplyByClass
.
Value
A vector or list of values, named by unique values of class
.
Author(s)
Lawrence Hudson
See Also
Examples
data(TL84)
# Sum body mass by category
ApplyByClass(TL84, 'M', 'category', sum)
# A more convenient way to sum body mass by category
SumMByClass(TL84)
# Sum body mass by kingdom. The 'Unclassified flagellates' node does not have a
# kingdom, so we get a value labelled '<unnamed>'.
SumMByClass(TL84, 'kingdom')
# Maximum body mass by category
ApplyByClass(TL84, 'M', 'category', max)
# A list of min and max M
ApplyByClass(TL84, 'M', 'category', range)
# A list of min and max M by kingom
ApplyByClass(TL84, 'M', 'kingdom', range)
# The same values as a matrix
do.call('rbind', ApplyByClass(TL84, 'M', 'kingdom', range))
# Broadstone Stream has some nodes in every category without M so all returned
# values are NA.
data(BroadstoneStream)
SumMByClass(BroadstoneStream)
# Get rid of the NA values
SumMByClass(BroadstoneStream, na.rm=TRUE)
[Package cheddar version 0.1-639 Index]