Get id of the parent of some taxa

parent(taxon_ids, taxo)

parents(taxon_ids, taxo)

Arguments

taxon_ids

internal, numeric ids of the taxa.

taxo

a taxonomy data.frame, typically from extract_taxo().

Value

A vector of taxon ids, as long as the input, containing the id of the parent of each element in the input.

Details

parent and parents are just synonyms. The function works per taxon but is vectorised over taxon_ids.

See also

Other taxonomy-related functions: ancestors(), as.taxo(), children(), descendants(), extract_taxo(), is_leaf(), lineage(), taxo_id(), taxo_name()

Examples

print(as.Node(taxo), "id")
#> levelName id #> 1 # NA #> 2 °--living 1 #> 3 ¦--fish 2 #> 4 ¦ °--egg 4 #> 5 °--mollusc 3 #> 6 ¦--snail 5 #> 7 ¦ °--egg 7 #> 8 °--squid 6
parent(3, taxo)
#> [1] 1
parent(1:4, taxo)
#> [1] NA 1 1 2
parent(c(5, NA), taxo)
#> [1] 3 NA
if (FALSE) parent(12, taxo)