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.

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.

Value

A modified safedata object with added taxonomic columns.

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.

See also

Examples

   set_example_safe_dir()
#> Loading and caching index
#> Validating directory
   beetle_morph <- load_safe_data(1400562, "MorphFunctTraits")
   beetle_morph <- add_taxa(beetle_morph)
   unset_example_safe_dir()
#> Loading and caching index
#> Validating directory