Learn R Programming

vegtable (version 0.1.7)

trait_stats: Statistics and proportion for taxon traits

Description

Calculation of statistics and proportions of taxon traits for plot observations or groups of observations, considering data relationships, taxonomic ranks and the handling of not available values.

The function trait_stats() calculates statistics for numeric variables, while the function trait_proportion() may be used for categorical variables. In the first case, a column with the name of the variable and a suffix will be generated, while in the second case, one additional column per selected trait level will be calculated.

Both mentioned functions offer the alternative weighted and unweighted calculations (e.g. calculations weighted by the abundance of species). In the particular case of trait_stats(), customized functions have to be defined as foo(x, w, ...), where w is the weight.

With the arguments taxon_level and merge_to the used taxonomic ranks can be defined, where the first one indicates which ranks have to be considered in the calculations and the second one determine the aggregation of taxa from a lower level to a parental one.

Formula methods allow for the calculation of multiple variables at once. The formulas have to be written as trait_1 + ... + trait_n ~ head_var.

Usage

trait_stats(trait, object, ...)

# S4 method for character,vegtable trait_stats( trait, object, FUN, head_var, taxon_level, merge_to, weight, suffix = "_stats", in_header = FALSE, ... )

# S4 method for formula,vegtable trait_stats(trait, object, weight, suffix = "_stats", in_header = FALSE, ...)

trait_proportion(trait, object, ...)

# S4 method for character,vegtable trait_proportion( trait, object, head_var, trait_level, taxon_level, merge_to, include_nas = TRUE, weight, suffix = "_prop", in_header = FALSE, ... )

# S4 method for formula,vegtable trait_proportion(trait, object, in_header = FALSE, ...)

Value

A data frame with the proportions of traits levels or statistics for the trait variable, or an object of class vegtable including those results at the slot header.

Arguments

trait

Either a character value indicating the name of trait variable or a formula including both arguments, trait and head_var.

object

A vegtable object.

...

Further arguments passed among methods. In the case of the formula method, arguments are passed to the character method.

FUN

A function usually defined as foo(x, ...) or as foo(x, w, ...) for weighted statistics.

head_var

Character value, the name of the variable at slot header to be used as aggregation level for the calculation of statistics or proportions. If not provided, the function will use ReleveID by default.

taxon_level

Character value indicating a selected taxonomic rank for the output.

merge_to

Character value indicating the taxonomic rank for aggregation of taxa. All ranks lower than the one indicated here will be assigned to the respective parents at the required taxonomic rank.

weight

Character value indicating the name of the variable at slot samples used as weight for the proportions. Usually the numeric abundance.

suffix

A suffix added to the name of the trait variable or to the levels of categorical trait variables. I is meant to avoid homonymous variables within the same object.

in_header

Logical value indicating whether the output should be inserted in the slot header or provided as data frame.

trait_level

Character vector indicating a selection of levels from a trait, in the case that some levels should be ignored in the output. Trait levels that are skipped at output will be still used for the calculation of proportions. This argument gets only applied for the character method.

include_nas

Logical value indicating whether NAs should be considered for the calculation of proportions or not.

Author

Miguel Alvarez kamapu78@gmail.com

Examples

Run this code
## Cocktail classification of plots
Wetlands_veg@header <- make_cocktail(Wetlands, Wetlands_veg, cover="percen")

## Calculation of proportion of Cyperaceae species in the plot
Wetlands_veg <- trait_proportion("FAMILY", Wetlands_veg, trait_level="Cyperaceae",
	weight="percen", include_nas=FALSE, in_header=TRUE)

## Display of proportions per plant community
boxplot(Cyperaceae_prop ~ Syntax, Wetlands_veg@header, col="grey")

Run the code above in your browser using DataLab