This function is used to retrieve the taxonomic hierarchy from an online database for each species in a data frame. This function requires the package 'taxize'

hierarchy(
  data,
  species,
  db = "gbif",
  ranks = c("kingdom", "phylum", "class", "order", "family", "genus", "species"),
  ID = TRUE,
  error.ret = TRUE
)

Arguments

data

A data frame

species

A character equal to the column name of the data frame that holds the species names

db

A character equal to the data base name for which you want to use to search for the taxonomic hierarchy. The possible data bases are Integrated Taxonomic Information System ('itis'), Global Biodiversity Information Facility ('gbif'), The National Center for Biotechnology Information ('ncbi'), the Encyclopedia of Life ('eol'), National Biodiversity Network ('nbn'), and Tropicos ('tropicos'). The default is 'gbif'. The function uses the first ID number returned by the taxize::get_id function.

ranks

A character or vector of rank names. The default is 'kingdom', 'phylum', 'class', 'order', 'family', 'genus', and 'species'.

error.ret

Logical. If TRUE then a column is added to the returned data frame that indicates if there was a some error in the retrieval of that species' hierarchy. error.ret = TRUE checks to see if the species name matches the species name returned in the hierarchy from the database.

Value

A data frame that has a column for each taxonomic level of a species taxonomic hierarchy

Examples

if (FALSE) {

library(here)
library(taxize)

herp <- read.csv(file.path(here(), 'data_raw', 'IBT_Herp_Records_v6.csv'), header=TRUE)

taxonomy <- hierarchy(data = herp, species = 'binomial', db = 'gbif')

}