View source: R/dyntaxa_api_functions.R
get_hierarchy | R Documentation |
This helper function retrieves the taxonomic hierarchy for a given taxon ID by recursively traversing its parent relationships in the provided dataset.
get_hierarchy(taxon_id, data)
taxon_id |
A character string representing the taxon ID for which the hierarchy is to be retrieved. |
data |
A data frame containing taxonomic information. Must include columns |
A character vector containing the hierarchy of parent scientificName
values, starting with the immediate parent and ascending.
# Example dataset
data <- tibble::tibble(
taxonId = c("1", "2", "3"),
parentNameUsageID = c(NA, "1", "2"),
scientificName = c("Kingdom", "Phylum", "Class")
)
# Get hierarchy for taxon ID "3"
SHARK4R:::get_hierarchy("3", data)
# [1] "Phylum" "Kingdom"
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.