从SPELL数据创建序列对象

Max*_*m.K 6 r traminer

我正在尝试seqdef使用SPELL格式创建一个序列对象.以下是我的数据示例:

spell <- structure(list(ID = c(1, 3, 3, 4, 5, 5, 6, 8, 9, 10, 11, 11, 
12, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 
15, 15, 15, 15, 15, 16, 16, 16, 16, 17, 17, 17, 18, 18, 18, 19, 
19), status = c(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 
1, 1, 2, 3, 1, 2, 3, 2, 3, 1, 1, 1, 3, 1, 3, 3, 1, 3, 1, 1, 1, 
1, 1, 3, 3, 1, 3, 1, 1, 1), time1 = c(1, 1, 57, 1, 1, 91, 1, 
1, 1, 1, 1, 104, 1, 1, 60, 109, 121, 1, 42, 47, 54, 64, 72, 78, 
85, 116, 1, 29, 39, 69, 74, 78, 88, 1, 16, 40, 68, 1, 30, 123, 
1, 39, 51, 1, 61), time2 = c(125, 57, 125, 125, 91, 125, 125, 
125, 125, 125, 104, 125, 125, 60, 109, 121, 125, 42, 47, 54, 
64, 72, 78, 85, 116, 125, 29, 39, 69, 74, 78, 88, 125, 16, 40, 
68, 125, 30, 123, 125, 39, 51, 125, 61, 125)), .Names = c("ID", 
"status", "time1", "time2"), row.names = c(NA, 45L), class = "data.frame")
Run Code Online (Sandbox Code Playgroud)

当我尝试定义序列对象时,会抛出一个奇怪的错误:

spell.seq <- seqdef(data=spell, informat="SPELL", id="ID", begin="time1", end="time2", 
                    status="status", limit=125,process=FALSE)

 [>] time axis: 1 -> 125
 [>] SPELL data converted into 17 STS sequences
 [>] 3 distinct states appear in the data: 
     1 = 1
     2 = 2
     3 = 3
 [>] state coding:
       [alphabet]  [label]  [long label] 
     1  1           1        1
     2  2           2        2
     3  3           3        3
 [>] 17 sequences in the data set
 [>] min/max sequence length: 125/125
Error in `row.names<-.data.frame`(`*tmp*`, value = value) : 
  invalid 'row.names' length
Run Code Online (Sandbox Code Playgroud)

但是,如果我通过seqformat保留相同的参数间接执行相同的操作,则不会抛出任何错误:

sts <- seqformat(data=spell,from="SPELL",to="STS",
                 id="ID",begin="time1",end="time2",status="status",
                 limit=125,process=FALSE)

seqs <- seqdef(sts,right="DEL")
Run Code Online (Sandbox Code Playgroud)

使用TramineR 1.8-5和R 3.0.0 Windows 7 64位.这是一个错误还是我做错了什么?提前致谢.

The*_*ell 4

seqdef()快速浏览一下如何设置的来源row.names就会发现它们是根据id参数的值设置的。

寻找?seqdef节目id

id
可选参数,用于设置序列对象的行名。如果为 NULL(默认),则行名取自输入数据。如果设置为“auto”,序列将从 1 到序列数进行编号。也可以指定长度等于序列数的行名向量。

从您传递的问题中的示例来看id="ID",它不符合这些标准。将此更改为允许命令按预期完成,并使用Yieldsid=NULL检查相等性。identical( spell.seq, seqs)true