## ==================
## the plot principle
## ==================
x <- c(1,2,2,2,3,4,1,2,2,2,3,4,1,1.5,2,2,3,3.5,4,4,1,2,2,2,3,4,
1,2,3,4,3.5,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4,1,2,1,2,
1,2,3,4,1,2)
y <- factor(c("A","B","B","B","C","A","A","B","B","B","C","A","A",
"B","B","C","C","C","C","C","A","B","B","B","C","A",
"A","A","A","A","A","B","A","A","A","A","A","A","A",
"A","A","A","A","A","A","A","A","A","A","A","A","A",
"A","A","A","A","A","B","C","A","A","A"))
id <- factor(c(1,1,1,1,1,1,2,2,2,2,2,2,3,3,3,3,3,3,3,3,4,4,4,4,4,4,
5,5,5,5,6,6,7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,
11,11,11,11,12,12,13,13,14,14,14,14,15,15))
ctplot(x,y,id,lwd.min=5,lwd.max=12,cex=1,
type="non-embeddable",alpha=0.9,
sf.cex=0.5,sf.cex.leaves=1,grid.scale=0.4)
## ====================
## plot the biofam data
## ====================
## loading the data and defining an event sequence dataset
## =======================================================
data(biofam)
lab <- c("Parent","Left","Married",
"Left+Marr","Child","Left+Child",
"Left+Marr+Child","Divorced")
biofam.seq <- seqdef(data=biofam,var=10:25,labels=lab)
biofam.TSE <- seqformat(data=biofam.seq,from="STS",to="TSE",
tevent=seqetm(seq=biofam.seq,method="state"))
biofam.TSE$event <- factor(biofam.TSE$event,levels=lab)
## plot the data
## =============
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,
y=biofam.TSE$event,
id=biofam.TSE$id,x.order=TRUE,
type="non-embeddable",lwd.max=10)
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,y=biofam.TSE$event,
id=biofam.TSE$id,split="first",layout=c(2,1),
grid.scale=0.5,x.order=TRUE)
par(mar=c(4,8,2,2))
ctplot(x=biofam.TSE$time,y=biofam.TSE$event,
id=biofam.TSE$id,
x.order=TRUE,x.orderalign="last",split="last",
layout=c(4,2),lwd.max=2.5,grid.scale=0.5)Run the code above in your browser using DataLab