Stores a taxonomy composed of taxon() objects organized in a tree structure. This differs from the hierarchies() class in how the taxon() objects are stored. Unlike hierarchies(), each taxon is only stored once and the relationships between taxa are stored in an edge list.

taxonomy(..., .list = NULL, named_by_rank = FALSE)

Arguments

...

Any number of object of class hierarchy() or character vectors.

.list

An alternate to the ... input. Any number of object of class hierarchy() or character vectors in a list. Cannot be used with ....

named_by_rank

(TRUE/FALSE) If TRUE and the input is a list of vectors with each vector named by ranks, include that rank info in the output object, so it can be accessed by out$taxon_ranks(). If TRUE, taxa with different ranks, but the same name and location in the taxonomy, will be considered different taxa.

Value

An R6Class object of class Taxonomy

See also

Examples

# Making a taxonomy object with vectors taxonomy(c("mammalia", "felidae", "panthera", "tigris"), c("mammalia", "felidae", "panthera", "leo"), c("mammalia", "felidae", "felis", "catus"))
#> <Taxonomy> #> 7 taxa: b. mammalia, c. felidae ... g. leo, h. catus #> 7 edges: NA->b, b->c, c->d, c->e, d->f, d->g, e->h
# Making a taxonomy object from scratch # Note: This information would usually come from a parsing function. # This is just for demonstration. x <- taxon( name = taxon_name("Notoryctidae"), rank = taxon_rank("family"), id = taxon_id(4479) ) y <- taxon( name = taxon_name("Notoryctes"), rank = taxon_rank("genus"), id = taxon_id(4544) ) z <- taxon( name = taxon_name("Notoryctes typhlops"), rank = taxon_rank("species"), id = taxon_id(93036) ) a <- taxon( name = taxon_name("Mammalia"), rank = taxon_rank("class"), id = taxon_id(9681) ) b <- taxon( name = taxon_name("Felidae"), rank = taxon_rank("family"), id = taxon_id(9681) ) cc <- taxon( name = taxon_name("Puma"), rank = taxon_rank("genus"), id = taxon_id(146712) ) d <- taxon( name = taxon_name("Puma concolor"), rank = taxon_rank("species"), id = taxon_id(9696) ) m <- taxon( name = taxon_name("Panthera"), rank = taxon_rank("genus"), id = taxon_id(146712) ) n <- taxon( name = taxon_name("Panthera tigris"), rank = taxon_rank("species"), id = taxon_id(9696) ) (hier1 <- hierarchy(z, y, x, a))
#> <Hierarchy> #> no. taxon's: 4 #> Mammalia / class / 9681 #> Notoryctidae / family / 4479 #> Notoryctes / genus / 4544 #> Notoryctes typhlops / species / 93036
(hier2 <- hierarchy(cc, b, a, d))
#> <Hierarchy> #> no. taxon's: 4 #> Mammalia / class / 9681 #> Felidae / family / 9681 #> Puma / genus / 146712 #> Puma concolor / species / 9696
(hier3 <- hierarchy(n, m, b, a))
#> <Hierarchy> #> no. taxon's: 4 #> Mammalia / class / 9681 #> Felidae / family / 9681 #> Panthera / genus / 146712 #> Panthera tigris / species / 9696
(hrs <- hierarchies(hier1, hier2, hier3))
#> <Hierarchies> #> no. hierarchies: 3 #> Mammalia / Notoryctidae / Notoryctes / Notoryctes typhlops #> Mammalia / Felidae / Puma / Puma concolor #> Mammalia / Felidae / Panthera / Panthera tigris
taxonomy(hier1, hier2, hier3)
#> <Taxonomy> #> 9 taxa: b. Mammalia, c. Notoryctidae ... j. Panthera tigris #> 9 edges: NA->b, b->c, b->d, c->e, d->f, d->g, e->h, f->i, g->j