Description Usage Arguments Value See Also Examples
Plots a 'heatmap' of a transition matrix
1 | plot_transition_matrix(transition_matrix, n_col_facets = 1)
|
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 |
ggplot object
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.