as_taxon {taxa}R Documentation

Convert to a taxon vector

Description

Convert other objects to taxon vectors. Compatible base R vectors can also be converted using the taxon constructor.

Usage

as_taxon(x, ...)

Arguments

x

An object to be converted to a taxon vector

...

Additional parameters.

Examples


# Convert a taxonomy object to a taxon vector
x <- taxonomy(taxon(name = c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo',
                             'Panthera tigris', 'Ursidae', 'Ursus', 'Ursus arctos'),
                    rank = c('order', 'family', 'genus', 'species',
                             'species', 'family', 'genus', 'species'),
                    id = taxon_id(c('33554', '9681', '9688', '9689',
                                    '9694', '9632', '9639', '9644'),
                                  db = 'ncbi'),
                    auth = c('Bowdich, 1821', 'Fischer de Waldheim, 1817', 'Oken, 1816', 'L., 1758',
                             'L., 1758', 'Fischer de Waldheim, 1817', 'L., 1758', 'L., 1758')),
              supertaxa = c(NA, 1, 2, 3, 3, 1, 6, 7))
names(x) <- letters[1:8]
as_taxon(x)

# Convert base R vectors
as_taxon(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo'))
as_taxon(factor(c('Carnivora', 'Felidae', 'Panthera', 'Panthera leo')))


[Package taxa version 0.4.3 Index]