[R] plotting order of lines in xyplot panels while using conditioning variable and groups

From: RICHARD PITMAN <richard.pitman3_at_btopenworld.com>
Date: Tue, 19 Jun 2007 11:19:51 +0100 (BST)


I am using the following code:

library(lattice)
data<-read.csv("data.csv")
attach(data)

fig<-xyplot(S_t~month|event,

       key = list(text=list(lab=c("Time to first CV event - Data",

"Survival post
first CV event - Model",

"Survival post
first MIA/CA event - Data",

"Survival post
first CVA event - Data",

"Survival post
first TIA event - Data",

"Survival post
first CVA/TIA event - Model"),

                               font=2,
                               cex=0.55),
                     lines=list(col=c("red",
                                      "magenta",
                                      "blue",
                                      "brown"),
                                type="l",
                                cex=0.55,
                                lwd=1.5,
                                pch=0:1),
                     corner=c(0,0),x=0.75,y=0.75),
       group  = group,
       index.cond = list(c(4,5,6,7,1,2,3)),
       type   = "l",
       lwd    = "3",
       ylim   = c(0,1.5),
       layout = c(4,2),
       col    = c("red","magenta","blue","brown"),
       pch    = 0:3,
       cex    = 0.5,
       ylab   = "cumulative probability",
       xlab   = "months",
     )

print(fig)

However, in each panel, the order in which the lines are printed is suboptimal as some shorter lines are obscured under longer lines. I am having some trouble finding a method to change the order in which curves are plotted in each panel. I have tried reordering the levels in data$group:

data$group<-factor(data$group,
levels=c("CV_model_event_1","CV model event 2","CV event
1","CV_event_2","CV_event_2_CVA","CV_event_2_TIA"))

but this changed nothing.

Any suggestions gratefully received.

TIA Richard



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 19 Jun 2007 - 10:26:18 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Jun 2007 - 19:32:15 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.