View source: R/sequence_plot.R
| sequence_plot | R Documentation |
Single entry point for three categorical-sequence visualisations.
type = "heatmap" (default): dense carpet, rows reordered
by sort / dendrogram (single panel).
type = "index": same data layout, but rows separated by
thin gaps (no dendrogram). Supports grouping via group or a
net_clustering, plus a ncol x nrow facet grid.
type = "distribution": dispatches to
distribution_plot.
sequence_plot(
x,
type = c("heatmap", "index", "distribution"),
sort = c("lcs", "frequency", "start", "end", "hamming", "osa", "lv", "dl", "qgram",
"cosine", "jaccard", "jw"),
tree = NULL,
group = NULL,
scale = c("proportion", "count"),
geom = c("area", "bar"),
na = TRUE,
normalize = FALSE,
trim = NULL,
trim_clusterwise = FALSE,
row_gap = 0,
dendrogram_width = 1.2,
k = NULL,
k_color = "white",
k_line_width = 2.5,
state_colors = NULL,
na_color = "grey90",
cell_border = NA,
frame = FALSE,
width = NULL,
height = NULL,
main = NULL,
show_n = TRUE,
time_label = "Time",
xlab = NULL,
y_label = NULL,
ylab = NULL,
tick = NULL,
ncol = NULL,
nrow = NULL,
combined = TRUE,
legend = NULL,
legend_size = NULL,
legend_title = NULL,
legend_ncol = NULL,
legend_border = NA,
legend_bty = "n"
)
x |
Wide-format sequence data. Accepts:
|
type |
One of |
sort |
Row-ordering strategy for heatmap / within-panel for index.
One of |
tree |
Optional |
group |
Optional grouping vector (length |
scale, geom, na |
Passed to |
normalize |
|
trim |
Optional time-axis truncation, to stop a few long
sequences from stretching the plot. Applies to all three types
(including the |
trim_clusterwise |
Grouped |
row_gap |
Fraction of row height used as vertical gap between
sequences in index plots. |
dendrogram_width |
Width ratio of the dendrogram panel (heatmap). |
k |
Optional integer. When supplied in |
k_color |
Colour for the cluster separator lines. Default
|
k_line_width |
Line width for the cluster separators. Default
|
state_colors |
Vector of colours, one per state. |
na_color |
Colour for |
cell_border |
Cell border colour. |
frame |
If |
width, height |
Optional device dimensions in inches. When supplied,
opens a new graphics device via |
main |
Plot title. |
show_n |
Append |
time_label, xlab |
X-axis label. |
y_label, ylab |
Y-axis label (distribution only). |
tick |
Show every Nth x-axis label. |
ncol, nrow |
Facet grid dimensions (index + distribution).
Ignored when |
combined |
Index and distribution types only. When |
legend |
Legend position: |
legend_size |
Legend text size. |
legend_title |
Optional legend title. |
legend_ncol |
Number of legend columns. |
legend_border |
Swatch border colour. |
legend_bty |
|
For base-graphics types, invisibly a list describing the plot
(shape depends on type). For an mcml input, a ggplot
object.
distribution_plot, build_clusters,
build_mcml
sequence_plot(trajectories)
sequence_plot(trajectories, type = "index")
sequence_plot(trajectories, type = "distribution")
# Multichannel MCML view: one channel per cluster + a macro Summary.
fit <- build_mcml(
group_regulation_long,
clusters = list(Cognitive = c("discuss", "synthesis", "consensus", "cohesion"),
Regulation = c("plan", "monitor", "adapt", "coregulate"),
Affective = "emotion"),
actor = "Actor", action = "Action", time = "Time")
sequence_plot(fit) # multichannel carpet
sequence_plot(fit, type = "distribution") # prevalence + NA band
sequence_plot(fit, type = "distribution", normalize = TRUE) # seqdplot (sums to 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.