在 TraMineR 中,函数 seqtransn 允许计算各个序列中的转换数 .
TraMineR
seqtransn
我想知道:有了 TraMineR ,有没有办法确定单个序列中的转换次数,但每种类型的转换?
例如,如果我有三个不同状态的状态序列,我将有6个可能的转换 . 而且我想为每个人计算6个可能转换中每个转换的出现次数 .
预先感谢您的帮助,
最好,
我在这里向您展示 biofam 数据的前3个序列如何获得每个序列的不同可能转换的计数:
biofam
data(biofam) biofam.seq <- seqdef(biofam[1:3,10:25]) ## First, make each sequence an element of a list biofam.seq.list <- setNames(split(biofam.seq, seq(nrow(biofam.seq))), rownames(biofam.seq)) ## and apply seqtrate to each element of the list tr.count <- lapply(biofam.seq.list, seqtrate, count=TRUE) tr.count ## $`1167` ## [-> 0] [-> 1] [-> 3] [-> 6] ## [0 ->] 8 0 1 0 ## [1 ->] 0 0 0 0 ## [3 ->] 0 0 0 1 ## [6 ->] 0 0 0 5 ## ## $`514` ## [-> 0] [-> 1] [-> 3] [-> 6] ## [0 ->] 0 1 0 0 ## [1 ->] 0 9 1 0 ## [3 ->] 0 0 0 1 ## [6 ->] 0 0 0 3 ## ## $`1013` ## [-> 0] [-> 1] [-> 3] [-> 6] ## [0 ->] 6 1 0 0 ## [1 ->] 0 4 1 0 ## [3 ->] 0 0 0 1 ## [6 ->] 0 0 0 2
1 回答
我在这里向您展示
biofam
数据的前3个序列如何获得每个序列的不同可能转换的计数: