Aggregate data by given taxonomic rank
rankagg(data = NULL, datacol = NULL, rank = NULL, fxn = "sum")
A data.frame. Column headers must have capitalized ranks (e.g., Genus, Tribe, etc.) (data.frame)
The data column (character)
Taxonomic rank to aggregate by (character)
Arithmetic function or vector or functions (character)
if (require(vegan)) {
data(dune.taxon, dune, package='vegan')
dat <- dune.taxon
dat$abundance <- colSums(dune)
rankagg(data=dat, datacol="abundance", rank="Genus")
rankagg(data=dat, "abundance", rank="Family")
rankagg(data=dat, "abundance", rank="Genus", fxn="mean")
rankagg(data=dat, "abundance", rank="Subclass")
rankagg(data=dat, "abundance", rank="Subclass", fxn="sd")
}
#> Loading required package: vegan
#> Loading required package: permute
#> Loading required package: lattice
#> This is vegan 2.6-6.1
#> Subclass sd
#> 1 Bryidae 27.57716
#> 2 Magnoliidae 18.45558