View source: R/transition_counts.R
calculate_transition_counts | R Documentation |
This function calculates the transition counts between elements in a set of sequences. It creates a matrix where each element represents the number of times a transition occurs from one element to another.
calculate_transition_counts(sequences)
sequences |
A vector of character strings, where each string represents a sequence of elements separated by spaces. Elements should be labeled with prefixes (e.g., "e1", "e2"). |
The function assumes that elements in the sequences are labeled with prefixes (e.g., "e1", "e2"), which are stripped to extract the integer labels for counting. The matrix is initialized to be of size num_elements x num_elements
, where num_elements
should be defined in your script or session. Ensure that num_elements
is set to the correct number of unique elements before running this function.
A matrix where the entry at [i, j]
represents the number of times an element labeled i
is followed by an element labeled j
across all sequences.
sequences <- c("e1 e2 e3", "e2 e3 e1", "e1 e3")
num_elements <- 3
calculate_transition_counts(sequences)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.