Get the ids of taxa from their names

taxo_id(taxon_names, taxo)

Arguments

taxon_names

vector of character strings with taxonomic names

taxo

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

Value

A vector ids, one for each element of taxon_names. Currently, this does not disambiguate between taxa with the same name and just returns the id of the first match in the taxonomy.

See also

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

Examples

taxo
#> id parent_id name #> 1 1 NA living #> 2 2 1 fish #> 3 3 1 mollusc #> 4 4 2 egg #> 5 5 3 snail #> 6 6 3 squid #> 7 7 5 egg
taxo_id("squid", taxo)
#> [1] 6
taxo_id("foo", taxo)
#> [1] NA
# NB: taxo_id("egg", taxo)
#> [1] 4