label_clusters: Label clusters consistently

Description Usage Arguments Value Examples

Description

Returns cluster labels that match the clusters in sequenchr::plot_dendrogram branches left-to-right.

Usage

1
label_clusters(.model, k)

Arguments

.model

an hclust model

k

the number of clusters

Value

a factor

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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, # states = mvad.scodes,
                   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')

label_clusters(cluster_model, k = 5)

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