I have a state sequence object with a grouping variable that has 6 levels. I would like to create 3 sequence index plots, one for levels 1 and 2, one for levels 3 and 4, and one for levels 5 and 6, and a legend as a separate plot. These will be exported to create 3 slides in a presentation.

The group= option in seqIplot does not subset the data. I tried to subset the data frame to create 3 state sequence objects but not all levels have the same alphabet so that is not a viable solution. What is an easy way to plot a subset of groups?

有帮助吗?

解决方案

You can use a subset by indexing the state sequence object and the grouping variable. If you have a state sequence object called "myseq", a subset vector called "subset" and the data frame where your group variable is stored called "my.data.frame":

 seqIplot(myseq[subset, ], group=my.data.frame$mygroup[subset])

For instance, you can build the subset vector using

 subset <- my.data.frame$mygroup %in% levels(my.data.frame$mygroup)[1:2]

OR

 subset <- my.data.frame$mygroup %in% c("value1", "value2")

Hope this helps

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top