Learn R Programming

taxize (version 0.9.100.1)

get_tsn: Get the TSN code for a search term.

Description

Retrieve the taxonomic serial numbers (TSN) of a taxon from ITIS.

Usage

get_tsn(
  sci_com,
  searchtype = "scientific",
  accepted = FALSE,
  ask = TRUE,
  messages = TRUE,
  rows = NA,
  searchterm = NULL,
  ...
)

as.tsn(x, check = TRUE)

# S3 method for tsn as.tsn(x, check = TRUE)

# S3 method for character as.tsn(x, check = TRUE)

# S3 method for list as.tsn(x, check = TRUE)

# S3 method for numeric as.tsn(x, check = TRUE)

# S3 method for data.frame as.tsn(x, check = TRUE)

# S3 method for tsn as.data.frame(x, ...)

get_tsn_( sci_com, messages = TRUE, searchtype = "scientific", accepted = TRUE, rows = NA, searchterm = NULL, ... )

Value

A vector of taxonomic identifiers as an S3 class. If a taxon is not found an NA is given. If more than one identifier is found the function asks for user input if ask = TRUE, otherwise returns NA. If ask=FALSE and rows does not equal NA, then a data.frame is given back, but not of the uid class, which you can't pass on to other functions as you normally can.

See get_id_details for further details including attributes and exceptions

Arguments

sci_com

character; A vector of common or scientific names. Or, a taxon_state object (see taxon-state)

searchtype

character; One of 'scientific' or 'common', or any unique abbreviation

accepted

logical; If TRUE, removes names that are not accepted valid names by ITIS. Set to FALSE (default) to give back both accepted and unaccepted names.

ask

logical; should get_tsn be run in interactive mode? If TRUE and more than one TSN is found for the species, the user is asked for input. If FALSE NA is returned for multiple matches.

messages

logical; should progress be printed?

rows

numeric; Any number from 1 to infinity. If the default NA, all rows are considered. Note that this function still only gives back a tsn class object with one to many identifiers. See get_tsn_() to get back all, or a subset, of the raw data that you are presented during the ask process.

searchterm

Deprecated, see sci_com

...

Ignored

x

Input to as.tsn

check

logical; Check if ID matches any existing on the DB, only used in as.tsn()

See Also

classification()

Other taxonomic-ids: get_boldid(), get_eolid(), get_gbifid(), get_ids(), get_iucn(), get_natservid(), get_nbnid(), get_pow(), get_tolid(), get_tpsid(), get_uid(), get_wiki(), get_wormsid()

Examples

Run this code
if (FALSE) {
get_tsn("Quercus douglasii")
get_tsn("Chironomus riparius")
get_tsn(c("Chironomus riparius","Quercus douglasii"))
splist <- c("annona cherimola", 'annona muricata', "quercus robur",
		"shorea robusta", "pandanus patina", "oryza sativa", "durio zibethinus")
get_tsn(splist, messages=FALSE)

# specify rows to limit choices available
get_tsn('Arni')
get_tsn('Arni', rows=1)
get_tsn('Arni', rows=1:2)

# When not found
get_tsn("howdy")
get_tsn(c("Chironomus riparius", "howdy"))

# Using common names
get_tsn("black bear", searchtype="common")

# Convert a tsn without class information to a tsn class
as.tsn(get_tsn("Quercus douglasii")) # already a tsn, returns the same
as.tsn(get_tsn(c("Chironomus riparius","Pinus contorta"))) # same
as.tsn(19322) # numeric
as.tsn(c(19322,129313,506198)) # numeric vector, length > 1
as.tsn("19322") # character
as.tsn(c("19322","129313","506198")) # character vector, length > 1
as.tsn(list("19322","129313","506198")) # list, either numeric or character
## dont check, much faster
as.tsn("19322", check=FALSE)
as.tsn(19322, check=FALSE)
as.tsn(c("19322","129313","506198"), check=FALSE)
as.tsn(list("19322","129313","506198"), check=FALSE)

(out <- as.tsn(c(19322,129313,506198)))
data.frame(out)
as.tsn( data.frame(out) )

# Get all data back
get_tsn_("Arni")
get_tsn_("Arni", rows=1)
get_tsn_("Arni", rows=1:2)
get_tsn_(c("asdfadfasd","Pinus contorta"), rows=1:5)
}

Run the code above in your browser using DataLab