collapsibletree package is the best option to build
interactive dendrogram with R.
On the chart above, you can click a node to reveal the following branch that is currently collapsed.
The input must be a data frame that stores the hierarchical information.
Basically, each row describes a complete path from the root to the leaf.
In this example, the
warpbreaks dataset has 3 columns:
# Load library # install.packages("collapsibleTree") library(collapsibleTree) # input data must be a nested data frame: head(warpbreaks) # Represent this tree: p <- collapsibleTree( warpbreaks, c("wool", "tension", "breaks")) p # save the widget # library(htmlwidgets) # saveWidget(p, file=paste0( getwd(), "/HtmlWidget/dendrogram_interactive.html"))