View source: R/dyntaxa_api_functions.R
get_all_parents | R Documentation |
This helper function iteratively retrieves all parent taxa for a given set of initial taxon IDs, traversing up the taxonomic hierarchy until the root (taxa with no parents) is reached.
get_all_parents(data, initial_taxon_ids)
data |
A data frame containing taxonomic information with columns
|
initial_taxon_ids |
A character vector of initial taxon IDs for which
to retrieve all parent taxa. These IDs should correspond to the |
A tibble containing all parent taxa for the given initial taxon IDs,
including their taxonId
, parentNameUsageID
, and any other columns present
in the input data
.
# Example data
data <- tibble::tibble(
taxonId = c("1", "2", "3", "4"),
parentNameUsageID = c(NA, "1", "1", "2"),
scientificName = c("Root", "Child1", "Child2", "Grandchild1")
)
# Find all parents of taxon IDs "3" and "4"
SHARK4R:::get_all_parents(data, initial_taxon_ids = c("3", "4"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.