The treecats
package defines a new subclass of an ordered
factor—“trees”— that are simple tree-like ontologies where values
lower on the tree inherit values above. treecats
allows for the
creation of tree factors, and provides functions for their basic
manipulation including querying up and down the tree, collapsing to a
level, and dropping unused levels.
“treecats” stands for “tree categories.” Yes, the package and its name
are inspired by Hadley Wickham’s
forcats
. The logo comes from John
Tenniel’s classic illustrations to Alice’s Adventures in Wonderland.
“Alice asked the Cheshire Cat, who was sitting in a tree, “What road do I take?” The cat asked, “Where do you want to go?” “I don’t know,” Alice answered. “Then,” said the cat, “it really doesn’t matter, does it?” — Lewis Carroll, Alice’s Adventures in Wonderland
You can install treecats from github with:
# install.packages("devtools")
devtools::install_github("bocinsky/treecats")
library(treecats)
c("John","Kyle","Molly") %>%
tct_tree()
#> [1] John Kyle Molly
#> attr(,"tct_levels")
#> IGRAPH befc7cf DN-- 3 2 --
#> + attr: name (v/c)
#> + edges from befc7cf (vertex names):
#> [1] John->Kyle Kyle->Molly
#> Levels: John < Kyle < Molly
Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.