plot_transition_matrix: Plot a transition matrix

Description Usage Arguments Value See Also Examples

View source: R/plotting.R

Description

Plots a 'heatmap' of a transition matrix

Usage

1

Arguments

transition_matrix

a transition matrix produced by sequenchr::transition_matrix()

n_col_facets

optional. If cluster_labels is provided then the number of facet columns

Value

ggplot object

See Also

transition_matrix

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
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)
seq_def_tidy <- tidy_sequence_data(mvad.seq)

trans_tidy <- transition_matrix(seq_def_tidy)
plot_transition_matrix(trans_tidy)

dist_matrix <- TraMineR::seqdist(seqdata = mvad.seq, method = "DHD")
cluster_model <- hclust(d = as.dist(dist_matrix), method = 'ward.D2')
cluster_labels <- stats::cutree(cluster_model, k = 5)

trans_tidy <- transition_matrix(seq_def_tidy, cluster_labels = cluster_labels)
plot_transition_matrix(trans_tidy)

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