I am running the code below to generate a list of TraMineR
sequence objects. The dataset can be found [here][1].
library(TraMineR)
sequences <- read.csv(file = "event-stream-20-l-m.csv", header = TRUE, nrows=10)
repo_names = colnames(sequences)
# 1. Loop across and define the 24 sequence objects & store them in sequence_objects
colpicks <- seq(10,240,by=10)
sequence_objects <- mapply(function(start,stop) seqdef(sequences[,start:stop]),
colpicks - 9, colpicks)
However, if I run:
test <- sequence_objects[1]
seqdist(test, indel=1, with.missing=FALSE, norm="maxdist")
The error message I receive is:
Error: [!] data is not a state sequence object, use 'seqdef' function to create one
How can it be that the mapply
using seqdef
does not create a list of sequence objects?
mapply
by default simplifies the return value.
As per the comment in the previous question, try including SIMPLIFY=FALSE
in the mapply
call.