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
)
An existing object of class safedata
The name of a taxon field in a safedata
for
which to add taxonomic data.
An existing taxon table for a dataset, as generated by
get_taxa
.
A string to be appended to taxon field names, primarily to discriminate between fields of multiple taxonomies are to be added.
A vector specifying a subset of taxonomy table field names to add.
A modified safedata
object with added taxonomic columns.
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.
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