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

Data tables in a safedata dataset can contain "taxa" fields, which tie an observation to a particular taxon used in the dataset. All datasets containing taxon observations provide taxonomic data about those taxa, validated against either NCBI or GBIF. The taxon table for an entire dataset can be accessed using get_taxa, but this function allows the taxonomic hierachy to be added for the specific taxa used in in a taxa field in a data worksheet.

Usage

add_taxa(
  obj,
  taxon_field = NULL,
  taxon_table = NULL,
  prefix = NULL,
  use_canon = FALSE
)

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.

use_canon

Add the canonical taxon name from the taxonomy database rather than the name used in the dataset.

Details

An existing taxon table from get_taxa can be provided to this 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 taxon hierarchy fields added from different taxon fields.

By default, the taxonomy data added to the table will use the original taxon name used in the dataset, even if that usage is considered a synonym or is merged in GBIF or NCBI (see get_taxa). The use_canon option can be set to TRUE to instead show the canonical taxon name used in the taxonomy database for synonomous or merged taxa.

Value

A modified safedata object with added taxonomic columns.

See Also

get_taxa

Examples

   set_example_safedata_dir()
   beetle_morph <- load_safe_data(1400562, "MorphFunctTraits")
   beetle_morph <- add_taxa(beetle_morph)
   set_example_safedata_dir(on=FALSE)

ImperialCollegeLondon/safe_data documentation built on Jan. 27, 2024, 9:51 a.m.