taxon: Taxon class

Description Usage Arguments Value See Also Examples

View source: R/taxon.R

Description

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

Used to store information about taxa, such as names, ranks, and IDs.

Usage

1
taxon(name = character(0), rank = NA, id = NA, auth = NA, .names = NA, ...)

Arguments

name

The names of taxa. Inputs with be coerced into a character vector if anything else is given.

rank

The ranks of taxa. Inputs with be coerced into a taxon_rank vector if anything else is given.

id

The ids of taxa. These should be unique identifier and are usually associated with a database. Inputs with be coerced into a taxon_id vector if anything else is given.

auth

The authority of the taxon. Inputs with be coerced into a taxon_authority vector if anything else is given.

.names

The names of the vector.

...

Additional arguments.

Value

An S3 object of class taxa_taxon

See Also

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

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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Create taxon name vector
x <- taxon(c('A', 'B', 'C'))
x <- taxon(name = c('Homo sapiens', 'Bacillus', 'Ascomycota', 'Ericaceae'),
           rank = c('species', 'genus', 'phylum', 'family'),
           id = taxon_id(c('9606', '1386', '4890', '4345'), db = 'ncbi'),
           auth = c('Linnaeus, 1758', 'Cohn 1872', NA, 'Juss., 1789'))
names(x) <- c('a', 'b', 'c', 'd')

# Get parts of the taxon name vector
tax_name(x)
tax_rank(x)
tax_id(x)
tax_db(x)
tax_auth(x)
tax_author(x)
tax_date(x)
tax_cite(x)

# Set parts of the taxon name vector
tax_name(x) <- tolower(tax_name(x))
tax_rank(x)[1] <- NA
tax_name(x)['b'] <- 'Billy'
tax_id(x) <- '9999'
tax_db(x) <- 'itis'
tax_auth(x) <- NA
tax_author(x)[2:3] <- c('Joe', 'Billy')
tax_date(x) <- c('1999', '2013', '1796', '1899')
tax_cite(x)[1] <- 'Linnaeus, C. (1771). Mantissa plantarum altera generum.'

# Manipulate taxon name vectors
x[1:3]
x[tax_rank(x) > 'family']
x['b'] <- NA
x[c('c', 'd')] <- 'unknown'
is.na(x)

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

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

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