# NOT RUN {
collapsibleTree(warpbreaks, c("wool", "tension", "breaks"))
# Data from US Forest Service DataMart
species <- read.csv(system.file("extdata/species.csv", package = "collapsibleTree"))
collapsibleTree(df = species, c("REGION", "CLASS", "NAME"), fill = "green")
# Visualizing the order in which the node colors are filled
library(RColorBrewer)
collapsibleTree(
warpbreaks, c("wool", "tension"),
fill = brewer.pal(9, "RdBu"),
fillByLevel = TRUE
)
collapsibleTree(
warpbreaks, c("wool", "tension"),
fill = brewer.pal(9, "RdBu"),
fillByLevel = FALSE
)
# Tooltip can be mapped to an attribute, or default to leafCount
collapsibleTree(
warpbreaks, c("wool", "tension", "breaks"),
tooltip = TRUE,
attribute = "breaks"
)
## collapsibleTree.Node example
species <- read.csv(system.file("extdata/species.csv", package = "collapsibleTree"))
hierarchy <- c("REGION", "CLASS", "NAME")
species$pathString <- paste(
"species",
apply(species[,hierarchy], 1, paste, collapse = "//"),
sep = "//"
)
df <- data.tree::as.Node(species, pathDelimiter = "//")
collapsibleTree(df)
# Using a flat relationship-style data frame with tooltips
Relationships <- data.frame(
Parent=c(".",".","A", "A", "A", "B", "B", "C", "E", "E", "F", "K", "K", "M", "M"),
Child=c("A","K","B", "C", "D", "E", "F", "G", "H", "I", "J", "L", "M", "N", "O"),
Value=1:15
)
tree <- data.tree::FromDataFrameNetwork(Relationships, "Value")
# Define root node value as 0
tree$Value <- 0
# Create tree diagram with the aggregation function of identity
collapsibleTree(tree, tooltip=TRUE, attribute="Value", aggFun=identity)
# }
Run the code above in your browser using DataLab