add_taxa: Add a taxonomic hierarchy to a SAFE data worksheet.

View source: R/taxa.R

add_taxaR Documentation

Add a taxonomic hierarchy to a SAFE data worksheet.

Description

All datasets containing taxon observations provide taxonomic data (see get_taxa) that can be linked to rows in data worksheets that contain "taxa" fields. This function matches the taxonomic hierarchy for a dataset for a given taxon field in a data worksheet and inserts fields to show that hierarchy.

Usage

add_taxa(
  obj,
  taxon_field = NULL,
  taxon_table = NULL,
  prefix = NULL,
  which = NULL
)

Arguments

obj

An existing object of class safedata

taxon_field

The name of a taxon field in a safedata for which to add taxonomic data.

taxon_table

An existing taxon table for a dataset, as generated by get_taxa.

prefix

A string to be appended to taxon field names, primarily to discriminate between fields of multiple taxonomies are to be added.

which

A vector specifying a subset of taxonomy table field names to add.

Details

An existing taxon table can be provided to the function, but the table will be automatically loaded if no table is provided. If a data worksheet only contains a single taxon field, then that field will be used automatically, otherwise users have to specify which taxon field to use. A prefix can be added to taxon fields in order to discrimate between fields from multuple taxon fields. By default, the function adds all of the fields included in the output of get_taxa, but which allows a subset of field names to be used.

Value

A modified safedata object with added taxonomic columns.

See Also

get_taxa

Examples

   set_example_safe_dir()
   beetle_morph <- load_safe_data(1400562, "MorphFunctTraits")
   beetle_morph <- add_taxa(beetle_morph)
   unset_example_safe_dir()

safedata documentation built on April 25, 2022, 5:05 p.m.