taxon_rank: Taxon rank class

Description Usage Arguments Value See Also Examples

View source: R/taxon_rank.R

Description

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

Used to store taxon ranks, possibly associated with a taxonomy database. This is typically used to store taxon ranks in taxon objects.

Usage

1
2
3
4
5
6
taxon_rank(
  rank = character(),
  .names = NULL,
  levels = NULL,
  guess_order = TRUE
)

Arguments

rank

Zero or more taxonomic rank names. Inputs will be transformed to a character vector.

.names

The names of the vector

levels

A named numeric vector indicating the names and orders of possible taxonomic ranks. Higher numbers indicate for fine-scale groupings. Ranks of unknown order can be indicated with NA instead of a number.

guess_order

If TRUE and no rank order is given using numbers, try to guess order based on rank names.

Value

An S3 object of class taxa_taxon_rank

See Also

Other classes: taxon_authority(), taxon_db(), taxon_id(), 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
28
29
30
31
32
33
# Making new objects
x <- taxon_rank(c('species', 'species', 'phylum', 'family'))

# Specifiying level order
taxon_rank(c('A', 'B', 'C', 'D', 'A', 'D', 'D'),
           levels = c('D', 'C', 'B', 'A'))
taxon_rank(c('A', 'B', 'C', 'D', 'A', 'D', 'D'),
           levels = c(D = NA, A = 10, B = 20, C = 30))
names(x) <- c('a', 'b', 'c', 'd')

# Manipulating objects
as.character(x)
as.factor(x)
as.ordered(x)
x[2:3]
x[x > 'family'] <- taxon_rank('unknown')
x[1] <- taxon_rank('order')
x['b']
x['b'] <- 'order'

# Using 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)

# Trying to add an unknown level as a character causes an error
#x[2] <- 'superkingdom'

# But you can add a new level using taxon_rank objects
x[2] <- taxon_rank('superkingdom')

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