plt_dend: Plot dendrogram.

View source: R/plt_dend.R

plt_dendR Documentation

Plot dendrogram.

Description

Visualize hierarchical clustered object with different colored clusters and leaf labels.

Usage

plt_dend(
  hc,
  n_clusters,
  label_size = 0.8,
  title = "Hiearchical Clustering Result",
  subtitle = NULL,
  xlab = NULL,
  ylab = NULL
)

Arguments

hc

Object returned by 'hclust()'.

n_clusters

Integer. Number of clusters.

label_size

Numeric. Size (default = 0.8) of text labels for the leaves.

title

String. Plot title (default = "Hiearchical Clustering Result").

subtitle

String. Plot subtitle (default = NULL).

xlab

String. Label of the x-axis (default = NULL).

ylab

String. Label of the y-axis (default = NULL).

Value

A ggplot2 dendrogram.

Examples

data(USArrests)
dd = dist(scale(USArrests), method = "euclidean")
hc = hclust(dd, method = "ward.D2")
plt_dend(hc, 2)
plt_dend(hc, 4, label_size = 0.5)
plt_dend(hc, 5)

cabaceo/shinymod documentation built on Sept. 8, 2023, 12:23 p.m.