A dendrogram (or tree diagram) is a network structure. It is constituted of a root node that gives birth to several nodes connected by edges or branches. The last nodes of the hierarchy are called leaves. Many options are available to build one with R. This sections aims to lead you toward the best strategy for your data.
Two types of dendrogram
Dendrograms can be built from:
ggraph package is the best option to build a
dendrogram from hierarchical data with R. It is based on the grammar
of graphic and thus follows the same logic that
Go further with ggraph: edge style, general layout, node features, adding labels, and more.
collapsibletree package is an htmlwidget: it
automatically builds collapsible interactive tree diagram. On the
chart below, click a node to reveal the next branch, and zoom
in/out if necessary.
Hierarchical clustering is a common task in data science and can be
performed with the
hclust() function in R. The following
examples will guide you through your process, showing how to prepare
the data, how to run the clustering and how to build an appropriate
chart to visualize its result.
Basic clustering process
Learn how to format your data, compute distance between samples, run the clusterisation and visualize the result.
dendextend package allows to go one step further in
term of dendrogram customization. Here is a set of examples showing
the main possibilities, like adding color bar on the bottom, drawing 2
trees face to face and more.
The set() function
An introduction to the set function that allows to customize node and label features.