plot_dendrogram: Plot a dendrogram colored by cluster

Description Usage Arguments Value Examples

View source: R/plotting.R

Description

Plots a dendrogram where the colors of the segments represent cluster membership. Note that the cluster labels may not match the cluster labels in other sequenchr::plot_* functions.

Usage

1
plot_dendrogram(cluster_model, k, h = 100)

Arguments

cluster_model

a clustering model such as the output from hclust

k

the number of clusters

h

the minimum height to plot the segments. A lower height results in decreased performance

Value

ggplot object

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
library(TraMineR)
data(mvad)
seqstatl(mvad[, 17:86])
mvad.alphabet <- c("employment", "FE", "HE", "joblessness", "school",
                   "training")
mvad.labels <- c("employment", "further education", "higher education",
                 "joblessness", "school", "training")
mvad.seq <- seqdef(mvad, 17:86, alphabet = mvad.alphabet,
                   labels = mvad.labels, xtstep = 6)
dist_matrix <- TraMineR::seqdist(seqdata = mvad.seq, method = "DHD")
cluster_model <- hclust(d = as.dist(dist_matrix), method = 'ward.D2')
plot_dendrogram(cluster_model, 5)

joemarlo/sequenchr documentation built on Sept. 29, 2021, 12:23 a.m.