level_hierarchy: Order of Hierarchical Levels in Soil Taxonomy

View source: R/hierarchy.R

level_hierarchyR Documentation

Order of Hierarchical Levels in Soil Taxonomy

Description

Creates an ordered factor such that different levels (the values used in level arguments to various SoilTaxonomy package functions) in the Soil Taxonomy hierarchy can be distinguished or compared to one another.

Usage

level_hierarchy(
  x = c("order", "suborder", "greatgroup", "subgroup", "family"),
  family = TRUE,
  as.is = FALSE
)

Arguments

x

Passed as input to factor(); defaults to full set: "order", "suborder", "greatgroup", "subgroup", "family",

family

Allow "family" as input in x? Used for validating inputs that must be a "taxon above family".

as.is

Return x "as is" (after validation)? Shorthand for unclass(taxon_hierarchy()) to return simple character vector.

Details

The levels of Soil Taxonomy hierarchy include: "family", "subgroup", "greatgroup", "suborder", "order". The "order" is a level above "suborder". "subgroup" and above are "taxa above family". Note: "family" is always included as the "lowest" level when the result is an ordered factor, even when family-level input is disallowed by family=FALSE.

Value

An ordered factor with the values "order", "suborder", "greatgroup", "subgroup". or character when as.is=TRUE.

Examples


# is great group a taxon above family?

level_hierarchy("greatgroup") > "family"

# is order lower level than suborder?
level_hierarchy("order") < "suborder"

# what levels are above or equal to a particular taxon's level?
level_hierarchy(as.is = TRUE)[level_hierarchy() >= taxon_to_level("aquisalids")]

## this produces an error (used for checking for taxa above family)
# level_hierarchy("family", family = FALSE)

SoilTaxonomy documentation built on Nov. 17, 2023, 1:07 a.m.