View source: R/sequence-networks.R
| create_transition_network | R Documentation |
Create a transition network from ordered sequences
create_transition_network(
data,
sequence_id_col = "sequence_id",
order_col = "sequence_order",
state_col = "state",
group_cols = NULL,
order = 1L,
include_self = TRUE,
normalise = c("count", "from", "global"),
smoothing = 0,
context_separator = " > "
)
data |
Long-format sequence data or a prepared result. |
sequence_id_col, order_col, state_col |
Sequence columns. |
group_cols |
Optional grouping columns constant within sequence. |
order |
Markov order. |
include_self |
Include first-order self-transitions. |
normalise |
Edge weight scale: counts, conditional probabilities from each context, or global shares. |
smoothing |
Non-negative additive smoothing applied to observed edges. |
context_separator |
Separator used for higher-order contexts. |
A data frame of class gp3_transition_network containing context,
next state, counts, weights, sequence prevalence, and group columns.
sequences <- data.frame(
sequence_id = rep(c("s1", "s2", "s3", "s4"), each = 4L),
sequence_order = rep(1:4, times = 4L),
state = c("A", "B", "C", "D", "A", "B", "C", "C",
"D", "C", "B", "A", "D", "C", "A", "A"),
group = rep(c("g1", "g2"), each = 8L),
stringsAsFactors = FALSE
)
create_transition_network(sequences, normalise = "from")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.