% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/lowest_common.R
\name{lowest_common}
\alias{lowest_common}
\alias{lowest_common.default}
\alias{lowest_common.uid}
\alias{lowest_common.tsn}
\alias{lowest_common.gbifid}
\alias{lowest_common.tolid}
\title{Retrieve the lowest common taxon and rank for a given taxon name or ID}
\usage{
lowest_common(...)

\method{lowest_common}{default}(
  sci_id,
  db = NULL,
  rows = NA,
  class_list = NULL,
  low_rank = NULL,
  x = NULL,
  ...
)

\method{lowest_common}{uid}(sci_id, class_list = NULL, low_rank = NULL, ...)

\method{lowest_common}{tsn}(sci_id, class_list = NULL, low_rank = NULL, ...)

\method{lowest_common}{gbifid}(sci_id, class_list = NULL, low_rank = NULL, ...)

\method{lowest_common}{tolid}(sci_id, class_list = NULL, low_rank = NULL, ...)
}
\arguments{
\item{...}{Other arguments passed to \code{\link[=get_tsn]{get_tsn()}}, \code{\link[=get_uid]{get_uid()}},
\code{\link[=get_gbifid]{get_gbifid()}}, \code{\link[=get_tolid]{get_tolid()}}}

\item{sci_id}{Vector of taxa names (character) or id (character or numeric) to
query.}

\item{db}{character; database to query. either \code{ncbi}, \code{itis}, \code{gbif},
\code{tol}. If using ncbi, we recommend getting an API key;
see \link{taxize-authentication}}

\item{rows}{(numeric) Any number from 1 to infinity. If the default NA,
all rows are considered. Note that this parameter is ignored if you pass in
a taxonomic id of any of the acceptable classes: tsn, gbifid, tolid.
NCBI has a method for this function but rows doesn't work.}

\item{class_list}{(list) A list of classifications, as returned from
\code{\link[=classification]{classification()}}}

\item{low_rank}{(character) taxonomic rank to return, of length 1}

\item{x}{Deprecated, see \code{sci_id}}
}
\value{
NA when no match, or a data.frame with columns
\itemize{
\item name
\item rank
\item id
}
}
\description{
Retrieve the lowest common taxon and rank for a given taxon name or ID
}
\section{Authentication}{

See \link{taxize-authentication} for help on authentication
}

\examples{
\dontrun{
id <- c("9031", "9823", "9606", "9470")
id_class <- classification(id, db = 'ncbi')
lowest_common(id[2:4], db = "ncbi")
lowest_common(id[2:4], db = "ncbi", low_rank = 'class')
lowest_common(id[2:4], db = "ncbi", low_rank = 'family')
lowest_common(id[2:4], class_list = id_class)
lowest_common(id[2:4], class_list = id_class, low_rank = 'class')
lowest_common(id[2:4], class_list = id_class, low_rank = 'family')

# TOL
taxa <- c("Angraecum sesquipedale", "Dracula vampira",
  "Masdevallia coccinea")
(cls <- classification(taxa, db = "tol"))
lowest_common(taxa, db = "tol", class_list = cls)
lowest_common(get_tolid(taxa), class_list = cls)
xx <- get_tolid(taxa)
lowest_common(xx, class_list = cls)

spp <- c("Sus scrofa", "Homo sapiens", "Nycticebus coucang")
lowest_common(spp, db = "ncbi")
lowest_common(get_uid(spp))

lowest_common(spp, db = "itis")
lowest_common(get_tsn(spp))

gbifid <- c("2704179", "3119195")
lowest_common(gbifid, db = "gbif")

spp <- c("Poa annua", "Helianthus annuus")
lowest_common(spp, db = "gbif")
lowest_common(get_gbifid(spp))

cool_orchid <- c("Angraecum sesquipedale", "Dracula vampira",
  "Masdevallia coccinea")
orchid_ncbi <- get_uid(cool_orchid)
orchid_gbif <- get_gbifid(cool_orchid)

cool_orchids2 <- c("Domingoa haematochila", "Gymnadenia conopsea",
  "Masdevallia coccinea")
orchid_itis <- get_tsn(cool_orchids2)

orchid_hier_ncbi <- classification(orchid_ncbi, db = 'ncbi')
orchid_hier_gbif <- classification(orchid_gbif, db = 'gbif')
orchid_hier_itis <- classification(orchid_itis, db = 'itis')

lowest_common(orchid_ncbi, low_rank = 'class')
lowest_common(orchid_ncbi, class_list = orchid_hier_ncbi,
  low_rank = 'class')
lowest_common(orchid_gbif, low_rank = 'class')
lowest_common(orchid_gbif, orchid_hier_gbif, low_rank = 'class')
lowest_common(get_uid(cool_orchid), low_rank = 'class')
lowest_common(get_uid(cool_orchid), low_rank = 'family')

lowest_common(orchid_ncbi, class_list = orchid_hier_ncbi,
  low_rank = 'subfamily')
lowest_common(orchid_gbif, class_list = orchid_hier_gbif,
  low_rank = 'subfamily')

lowest_common(orchid_itis, class_list = orchid_hier_itis,
  low_rank = 'class')

## Pass in sci. names
nms <- c("Angraecum sesquipedale", "Dracula vampira", "Masdevallia coccinea")
lowest_common(x = nms, db = "ncbi")
lowest_common(x = nms, db = "gbif")
}
}
\author{
Jimmy O'Donnell \email{jodonnellbio@gmail.com}
Scott Chamberlain
}
