Convert a matrix to a cfda data.frame
matrixToCfd(X, times = NULL, labels = NULL, byrow = FALSE)
a data.frame in the cfda format
Other format:
convertToCfd()
,
cut_data()
,
remove_duplicated_states()
x <- matrix(
c(
"a", "b", "c", "c",
"c", "a", "a", "a",
"b", "c", "a", "b"
),
ncol = 4, byrow = TRUE,
dimnames = list(NULL, paste0("ind", 1:4))
)
matrixToCfd(x)
#> id time state
#> 1 ind1 1 a
#> 2 ind1 2 c
#> 3 ind1 3 b
#> 4 ind2 1 b
#> 5 ind2 2 a
#> 6 ind2 3 c
#> 7 ind3 1 c
#> 8 ind3 2 a
#> 9 ind3 3 a
#> 10 ind4 1 c
#> 11 ind4 2 a
#> 12 ind4 3 b