View source: R/dyntaxa_api_functions.R
add_hierarchy_column | R Documentation |
This function adds a new column, hierarchy
, to a dataset, where each row contains
the taxonomic hierarchy of parent scientificName
values for the given taxonId
.
The hierarchy is constructed using a recursive helper function.
add_hierarchy_column(data, data_dwca = NULL, verbose = TRUE)
data |
A data frame containing taxonomic information. Must include columns |
data_dwca |
A data frame representing the complete taxonomic dataset (e.g., full taxonomy table).
Must include the same columns as |
verbose |
Logical. If TRUE, the function will print additional messages to provide feedback on its progress. Default is TRUE. |
A data frame with an additional hierarchy
column. The hierarchy
column contains
a string representing the lineage of parent scientificName
values, separated by " > ".
# Example dataset
data <- tibble::tibble(
taxonId = c("1", "2", "3"),
parentNameUsageID = c(NA, "1", "2"),
scientificName = c("Kingdom", "Phylum", "Class")
)
# Add hierarchy column
data_with_hierarchy <- SHARK4R:::add_hierarchy_column(data)
print(data_with_hierarchy)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.