ancestors | R Documentation |
Get the ids of all ancestors of some taxa
ancestors(taxon_ids, taxo, n = Inf)
taxon_ids |
internal, numeric ids of the taxa. |
taxo |
a taxonomy data.frame, typically from |
n |
maximum number of levels to look up; n=1 gives the parents, n=2 gives the parents and the grand-parents, etc. |
Even with n=1
, the function is different from parent()
because it returns all unique parents for all elements of taxon_ids
, not one parent per element.
A vector of taxonomic ids containing the input taxon_ids
and all their ancestors. With a single taxon in taxon_ids
, the ancestors are in ordered from the taxon to the root of the tree: they define the lineage. When taxon_ids
contains multiple taxa, the order is non-trivial.
Other taxonomy-related functions:
as.taxo()
,
children()
,
descendants()
,
extract_taxo()
,
is_leaf()
,
lineage()
,
parent()
,
taxo_id()
,
taxo_name()
print(as.Node(taxo), "id")
ancestors(5, taxo)
ancestors(1, taxo)
ancestors(NA, taxo)
ancestors(1:7, taxo)
ancestors(6, taxo, n=1)
ancestors(6, taxo, n=2)
ancestors(6, taxo, n=3)
ancestors(6, taxo, n=10)
# NB:
ancestors(5:6, taxo, n=1)
parent(5:6, taxo)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.