plot_hclust.Rd
Run hierarchical clustering on the given data matrix and plot the resulting dendrogram using a pretty theme. Also allows for coloring of the leaf nodes.
plot_hclust(
data,
leaf_labels = rownames(data),
leaf_colors = NULL,
dist_metric = "euclidean",
dist_matrix = NULL,
linkage = "ward.D",
text_size = 10,
title = NULL,
show_plot = F
)
Data matrix or data.frame on which to perform hierarchical clustering.
(Optional) Text labels for leaf nodes (e.g., class/outcome labels).
(Optional) Data vector to use for coloring leaf nodes.
Distance metric for clustering (see [stats::dist()]).
(Optional) Distance matrix for clustering. Must provide
either dist_metric
or dist_matrix
.
Rype of linkage for hierarchical clustering (see [stats::hclust()]).
Numeric; size of text for leaf node labels.
Character string. Title of plot.
Logical. Should this plot be printed? Default FALSE
.
A list of three:
A ggplot object of the dendrogram.
Output of [stats::hclust()]
Hierarchical clustering dendrogram data. See output of [ggdendro::dendro_data()].
out <- plot_hclust(data = iris[, -5], leaf_labels = iris$Species,
leaf_colors = iris$Species)
out$plot