import_data {tna} | R Documentation |
Import Wide Format Sequence Data as Long Format Sequence Data
Description
This function transforms wide format data where features are in separate columns into a long format suitable for sequence analysis. It creates windows of data based on row order and generates sequence order within these windows.
Usage
import_data(data, cols, id_cols, window_size = 1, replace_zeros = TRUE)
Arguments
data |
A |
cols |
An |
id_cols |
A |
window_size |
An |
replace_zeros |
A |
Value
A data.frame
in long format with added columns for window and
sequence order.
See Also
Other data:
prepare_data()
,
print.tna_data()
,
simulate.tna()
Examples
data <- data.frame(
ID = c("A", "A", "B", "B"),
Time = c(1, 2, 1, 2),
feature1 = c(10, 0, 15, 20),
feature2 = c(5, 8, 0, 12),
feature3 = c(2, 4, 6, 8),
other_col = c("X", "Y", "Z", "W")
)
# Using a vector
long_data1 <- import_data(
data = data,
cols = c(feature1, feature2),
id_cols = c("ID", "Time"),
window_size = 2,
replace_zeros = TRUE
)
# Using a column range
long_data2 <- import_data(
data = data,
cols = feature1:feature3,
id_cols = c("ID", "Time"),
window_size = 2,
replace_zeros = TRUE
)