ancestors: Get ids of ancestors of a taxon

Description Usage Arguments Details See Also Examples

View source: R/taxo.R

Description

Get ids of ancestors of a taxon

Usage

1
ancestors(id, taxo, n = Inf)

Arguments

id

numerical ids of taxonomic classes (typically a single one)

taxo

a taxonomy data.frame, typically from extract_taxo

n

number of levels to look up; n=1 gives the parents, n=2 gives the grand-parents, etc.

Details

Even with n=1 function is different from [parent()] because it returns a vector of unique parents for all input id values, not necessarily in order.

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(taxo)
ancestors(6, taxo)
ancestors(5:7, taxo)
ancestors(1, taxo)
ancestors(NA, taxo)
ancestors(6, taxo, n=1)
ancestors(6, taxo, n=2)
ancestors(6, taxo, n=3)
ancestors(6, taxo, n=10)
# NB:
ancestors(5:7, taxo, n=1)
parent(5:7, taxo)

jiho/ecotaxar documentation built on June 28, 2018, 4:23 p.m.