as.taxo: Coerce a taxonomy data.frame to various formats

View source: R/taxo.R

as.taxoR Documentation

Coerce a taxonomy data.frame to various formats

Description

Coerce a taxonomy data.frame to various formats

Usage

as.taxo(x)

is.taxo(x)

## S3 method for class 'taxo'
as.list(x, ...)

## S3 method for class 'taxo'
as.Node(x, ...)

Arguments

x

a taxonomy data.frame, typically from extract_taxo().

...

passed to other methods.

Details

A taxonomy data.frame is just a regular data.frame with columns id, parent_id, and name. The links between the id and parent_id define the taxonomic hierarchy. It can be converted into an actual tree using data.tree::as.Node() and into a nested list.

See Also

Other taxonomy-related functions: ancestors(), children(), descendants(), extract_taxo(), is_leaf(), lineage(), parent(), taxo_id(), taxo_name()

Examples

taxo
as.Node(taxo)
print(as.Node(taxo), "id", "parent_id")
as.list(taxo)

# transforming into a taxonomy data.frame is just a mater of adding a class
df <- taxo
class(df)
is.taxo(df)
df <- as.data.frame(df)
class(df)
is.taxo(df)
df <- as.taxo(df)
class(df)
is.taxo(df)

## Not run: 
db <- db_connect_ecotaxa()
taxo <- extract_taxo(db, c(8000, 20000))
as.Node(taxo)

## End(Not run)

jiho/ecotaxar documentation built on Jan. 16, 2024, 12:26 a.m.