taxon_id: Taxon ID class

Description Usage Arguments Value See Also Examples

View source: R/taxon_id.R

Description

\Sexpr[results=rd, stage=render]{taxa2:::lifecycle("maturing")}

Used to store the ID corresponding to taxa, either arbitrary or from a particular taxonomy database. This is typically used to store taxon IDs in taxon objects.

Usage

1
taxon_id(id = character(), db = NA, .names = NULL)

Arguments

id

Zero or more taxonomic ids. Inputs will be transformed to a character vector if possible.

db

The name(s) of the database(s) associated with the IDs. If not NA (the default), the input must consist of names of databases in db_ref$get().

.names

The names that will be applied to the vector.

Value

An S3 object of class taxa_taxon_id

See Also

Other classes: taxon_authority(), taxon_db(), taxon_rank(), taxonomy(), taxon()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Making new objects
x <- taxon_id(c('A', 'B', 'C'))
x <- taxon_id(c('9606', '1386', '4890', '4345'), db = 'ncbi')
x <- taxon_id(c('9606', '1386', '4890', '4345'),
              db = c('ncbi', 'ncbi', 'itis', 'itis'))
names(x) <- c('a', 'b', 'c', 'd')

# Manipulating objects
as.character(x)
x[2:3]
x[2:3] <- 'ABC'
x[c('a', 'c')] <- '123'
x[['b']] <- taxon_id('123423', db = 'ncbi')
tax_db(x)
tax_db(x) <- 'nbn'
c(x, x)

# Using as columns in tables
tibble::tibble(x = x, y = 1:4)
data.frame(x = x, y = 1:4)

# Convert to tables
tibble::as_tibble(x)
as_data_frame(x)

# Trying to use an invalid ID with a specified database causes an error
#taxon_id('NOLETTERS', db = 'ncbi')

zachary-foster/taxa2 documentation built on Jan. 1, 2021, 1:48 p.m.