taxon_rank {taxa} | R Documentation |
Taxon rank class
Description
Used to store taxon ranks, possibly associated with a taxonomy database. This is typically used to store taxon ranks in taxon objects.
Usage
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
|
guess_order |
If |
Value
An S3
object of class taxa_taxon_rank
See Also
Other classes:
[.taxa_classification()
,
classification()
,
taxon()
,
taxon_authority()
,
taxon_db()
,
taxon_id()
Examples
# 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')
[Package taxa version 0.4.3 Index]