It can be a pain in the ass to get taxonomic names. For example, I sometimes need to get all the Class names for a set of species. This is a relatively easy problem using the ITIS API (example below).
The much harder problem is getting all the taxonomic names downstream. ITIS doesn’t provide an API method for this - well, they do (getHirerachyDownFromTSN), but it only provides direct children (e.g., the genera within a tribe - but it won’t give all the species within each genus).
So in the taxize package, we wrote a function called downstream, which allows you to get taxonomic names to any downstream point, e.g.:
get all Classes within Animalia,
get all Species within a Family
etc.
Install packages. You can get other packages from CRAN, but taxize is only on GitHub for now.
1
2
3
4
5
# install_github('ritis', 'ropensci') # uncomment if not already installed# install_github('taxize_', 'ropensci') # uncomment if not already# installedlibrary(ritis)library(taxize)
Get upstream taxonomic names.
1
2
3
4
5
6
# Search for a TSN by scientific namedf<-searchbyscientificname("Tardigrada")tsn<-df[df$combinedname%in%"Tardigrada","tsn"]# Get just one immediate higher taxonomic namegethierarchyupfromtsn(tsn=tsn)