我正在尝试查看具有特定子序列或子字符串的案例 . 在用户指南部分10.5.1-10.5.2中,它指定了如何查找具有特定子序列的案例:
mysubseqstr <- character(2)
mysubseqstr[1] <- "(Parent)-(Left)-(Left+Marr)"
mysubseqstr[2] <- "(Parent)-(Left+Marr)"
mysubseq <- seqefsub(bf.seqestate, strsubseq = mysubseqstr)
print(mysubseq)
Subsequence Support Count
1 (Parent)-(Left+Marr) 0.4870 974
2 (Parent)-(Left)-(Left+Marr) 0.2275 455
Computed on 2000 event sequences
Constraint Value
countMethod One by sequence
msubcount <- seqeapplysub(mysubseq, method = "count")
msubcount[1:3, ]
在这里回答了另一个问题(Find specific patterns in sequences,我可以列出包含子序列的序列:
rownames(msubcount)[msubcount[,1]==1]
但我无法弄清楚如何获得id的列表(在seqdef函数中使用id =选项定义)具有此子序列 .
1 回答
使用
seqdef
的id=
参数传递的ID用作状态序列对象的行名 . 假设你的状态序列对象是seq
并且你从它创建了事件序列对象bf.seqestate
(你没有在代码中显示它!),你得到包含你的子序列的序列的id:注意,我在这里使用
>
因为在seqeapplysub
中method = "count"
,你得到每个序列中子序列的出现次数,可以大于1 .