我有一个包含 24 个TraMineR
序列对象的列表。现在我想计算每个序列对象的最佳匹配距离(仅在每个对象内)并将其存储在一个新列表中,现在由 24 个 OM 距离对象(距离矩阵)组成。
数据集可以在这里找到。
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)
# 2. Calculate the costs for OM distances within each object
costs <- mapply(seqsubm(sequence_objects, method="TRATE"))
# 3. Calculate the OM distance objects for each sequence object
sequences.om <- seqdist(sequence_objects, method="OM", indel=1, sm=costs, with.missing=FALSE, norm="maxdist")
步骤 (1) 工作正常,但是当我进行到步骤 (2) 时,它告诉我:
Error in seqsubm(sequence_objects, method = "TRATE") :
[!] data is NOT a sequence object, see seqdef function to create one
这是很自然的,因为sequence_objects
不是序列对象,而是序列对象的列表。
如何将该seqsubm
函数应用于序列对象列表?