as.taxo.Rd
Coerce a taxonomy data.frame to various formats
as.taxo(x) is.taxo(x) # S3 method for taxo as.list(x, ...) # S3 method for 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#> id parent_id name #> 1 1 NA living #> 2 2 1 fish #> 3 3 1 mollusc #> 4 4 2 egg #> 5 5 3 snail #> 6 6 3 squid #> 7 7 5 egg#> levelName #> 1 # #> 2 °--living #> 3 ¦--fish #> 4 ¦ °--egg #> 5 °--mollusc #> 6 ¦--snail #> 7 ¦ °--egg #> 8 °--squid#> levelName id parent_id #> 1 # NA NA #> 2 °--living 1 NA #> 3 ¦--fish 2 1 #> 4 ¦ °--egg 4 2 #> 5 °--mollusc 3 1 #> 6 ¦--snail 5 3 #> 7 ¦ °--egg 7 5 #> 8 °--squid 6 3#> $living #> $living$fish #> $living$fish$egg #> [1] "" #> #> #> $living$mollusc #> $living$mollusc$squid #> [1] "" #> #> $living$mollusc$snail #> $living$mollusc$snail$egg #> [1] "" #> #> #> #> #> attr(,"class") #> [1] "taxo_list" "list"#> [1] "taxo" "data.frame"is.taxo(df)#> [1] TRUE#> [1] "data.frame"is.taxo(df)#> [1] FALSE#> [1] "taxo" "data.frame"is.taxo(df)#> [1] TRUE