sequences_to_long {AnimalSequences} | R Documentation |
Convert Sequences to Long Format
Description
This function converts a data frame with sequences into long format. It expands each sequence into individual rows, optionally including start and end times and covariates.
Usage
sequences_to_long(
sequences,
sequence = "sequence",
start_time = NULL,
end_time = NULL,
covariates = NULL
)
Arguments
sequences |
A data frame containing sequences. |
sequence |
Column name with the sequences. |
start_time |
Column name with the start time. Defaults to NULL. |
end_time |
Column name with the end time. Defaults to NULL. |
covariates |
A vector with column names of the covariates. Defaults to NULL. |
Value
A data frame in long format with sequences, start time, end time, duration, and covariates.
Examples
sequences <- data.frame(sequence = c('A B C', 'A B', 'A C', 'B C'),
covariate1 = c('X', 'Y', 'X', 'Y'),
covariate2 = c('M', 'N', 'M', 'N'))
sequences_to_long(sequences,
sequence = 'sequence',
covariates = c('covariate1', 'covariate2'))
[Package AnimalSequences version 0.2.0 Index]