我对R TraMineR包中的seqrplot函数有疑问,该函数绘制了代表性序列集。我有一个关于欧盟法律侵权诉讼的大数据集(由于程序的长度,我使用seqgranularity函数)并使用以下代码。
library(TraMineR)
library(TraMineRextras)
library(grDevices)
#example data
directives <-
structure(list(id = c(891L, 6826L, 9451L, 8816L), country_short = structure(c(2L,1L, 1L, 1L),
.Label = c("I", "P"), class = "factor"), year = c(1992L, 1981L, 1980L, 1980L),
federal = c(0L, 1L, 1L, 1L), admin = c(5331L,
1423L, 735L, 656L), pol = c(NA, NA, NA, 223L), adjud = c(NA, NA, NA, 330L),
postlit = c(NA_integer_, NA_integer_, NA_integer_, NA_integer_),
ADM = structure(c(2L, 1L, 4L, 3L), .Label = c("(ADM,1423)", "(ADM,5331)", "(ADM,656)",
"(ADM,735)"), class = "factor"), POL = structure(c(NA, NA, NA, 1L), .Label = "(POL,223)",
class = "factor"), ADJ = structure(c(NA, NA, NA, 1L), .Label = "(ADJ,330)",
class = "factor"), PLIT = structure(c(NA_integer_, NA_integer_, NA_integer_, NA_integer_),
.Label = character(0), class = "factor")), .Names = c("id", "country_short", "year", "federal",
"admin", "pol", "adjud", "postlit", "ADM", "POL", "ADJ", "PLIT"), row.names = c(NA, 4L), class = "data.frame")
directives.seq<-seqdef(data=directives, var=9:12, xtstep=364,
informat = "SPS", SPS.in=list(xfix="()",sdsep=","),
cpal=c("blue","gray","black","green"),
void="%", alphabet=c("ADM","POL","ADJ","PLIT"),
labels=c("Administration phase","Political phase","Adjudication phase","Post-litigation phase"))
directives.seq.month<-seqgranularity(directives.seq, tspan=30, method="first")
directives.om<-seqdist(directives.seq.month, full.matrix=FALSE, method="OM", indel=1, sm="TRATE")
seqrplot(directives.seq.month, diss=directives.om, group=directives$federal, criterion="dist", nrep=3)
但是,该图似乎没有考虑归因于序列对象的调色板。相反,它以黑色(see screenshot)返回代表性序列。我检查了我的par()设置,它们看起来很好,因为所有其他的图都是正确的颜色。或者有没有办法恢复par()的默认设置?我还尝试使用较小的子样本运行代码,但它没有改变结果。 有人知道如何解决这个问题吗?
非常感谢您提前!