as.taxo | R Documentation |
Coerce a taxonomy data.frame to various formats
as.taxo(x)
is.taxo(x)
## S3 method for class 'taxo'
as.list(x, ...)
## S3 method for class 'taxo'
as.Node(x, ...)
x |
a taxonomy data.frame, typically from |
... |
passed to other methods. |
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.
Other taxonomy-related functions:
ancestors()
,
children()
,
descendants()
,
extract_taxo()
,
is_leaf()
,
lineage()
,
parent()
,
taxo_id()
,
taxo_name()
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.