find_descendants: Find All Descendants of a Taxon

View source: R/dyntaxa_api_functions.R

find_descendantsR Documentation

Find All Descendants of a Taxon

Description

This helper function recursively finds all descendant taxa of a given taxon ID by traversing the parent-child hierarchy in the provided dataset.

Usage

find_descendants(taxon_id, data)

Arguments

taxon_id

A character string representing the taxon ID for which to find descendants.

data

A data frame containing taxonomic information with columns taxonId and parentNameUsageID.

Value

A tibble containing all descendants of the given taxon, including their taxonId, parentNameUsageID, and any other columns present in the input data.

Examples

# Example data
data <- tibble::tibble(
  taxonId = c("1", "2", "3", "4"),
  parentNameUsageID = c(NA, "1", "2", "2"),
  scientificName = c("Root", "Child1", "Child2", "Grandchild1")
)

# Find descendants of taxon "1"
SHARK4R:::find_descendants("1", data)


sharksmhi/SHARK4R documentation built on Jan. 9, 2025, 5:15 p.m.