I have a data.frame in long format, that I want to convert to a TraMineR
sequence object.
set.seed(1)
df <- data.frame(year = rep(1990:2010, 3),
id = rep(1:3, each = 21),
value = sample(10, 63, replace = TRUE))
AFAIK, none of the formats described in the manual support this format.
What would be an easy way to convert this data.frame to a sequence object? With id
the individual, year
the time and value
the state. One can convert first to wide (see answer), but I wonder whether this format is natively supported by TraMineR
.