Interactive dendrogram with R



This post describes how to use the CollapsibleTree package to build an interactive tree diagram. Explanation and reproducible code provided

Dendrogram section Data to Viz

The 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: wool, tension and breaks.

# 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"))

Related chart types


Grouped and Stacked barplot
Treemap
Doughnut
Pie chart
Dendrogram
Circular packing



Contact

This document is a work by Yan Holtz. Any feedback is highly encouraged. You can fill an issue on Github, drop me a message on Twitter, or send an email pasting yan.holtz.data with gmail.com.

Github Twitter