2013-04-06 51 views
3

我正在运行下面的代码来生成一个序列对象列表TraMineR。数据集可以在[这里]找到[1]。使用mapply在R/TraMineR中创建序列对象?

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) 

但是,如果我运行:

test <- sequence_objects[1] 
seqdist(test, indel=1, with.missing=FALSE, norm="maxdist") 

我收到的错误消息是:

Error: [!] data is not a state sequence object, use 'seqdef' function to create one 

这怎么可能,使用seqdefmapply创建一个列表序列对象?

+0

[通过列表中的序列对象进行循环?](http://stackoverflow.com/questions/15839403/looping-through-sequence-objects-in-a-list) – mnel 2013-04-07 23:17:54

回答

3

mapply默认情况下会简化返回值。

根据上一个问题的评论,请尝试在mapply调用中包括SIMPLIFY=FALSE