| convert_sequence_format | R Documentation |
Convert wide or long sequence data into frequency counts, one-hot encoding, edge lists, or follows format.
convert_sequence_format(
data,
seq_cols = NULL,
id_col = NULL,
action = NULL,
time = NULL,
format = c("frequency", "onehot", "edgelist", "follows")
)
data |
Data frame containing sequence data. |
seq_cols |
Character vector. Names of columns containing sequential
states (for wide format input). If NULL, all columns except |
id_col |
Character vector. Name(s) of the ID column(s). For wide format, defaults to the first column. For long format, required. Default: NULL. |
action |
Character or NULL. Name of the column containing actions/states (for long format input). If provided, data is treated as long format. Default: NULL. |
time |
Character or NULL. Name of the time column for ordering actions within sequences (for long format). Default: NULL. |
format |
Character. Output format:
|
A data frame in the requested format:
ID columns + one integer column per state with counts.
ID columns + one binary column per state (0/1).
ID columns + from and to columns.
ID columns + act and follows columns.
frequencies for building transition frequency matrices.
# Wide format input
seqs <- data.frame(V1 = c("A","B","A"), V2 = c("B","A","C"), V3 = c("A","C","B"))
convert_sequence_format(seqs, format = "frequency")
convert_sequence_format(seqs, format = "edgelist")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.