[R] x axis on sciplot

Richard M. Heiberger rmh at temple.edu
Mon Nov 27 03:31:29 CET 2006


You will need a numeric axis, not a factor axis, and control of both
the at= and labels= of the axis.  Here is an example using your
data and the lattice xyplot function.


try$visit.position <- try$visit
levels(try$visit.position)
levels(try$visit.position)[1] <- -20
levels(try$visit.position)

try$visit.position <- as.numeric(as.character(try$visit.position))
try$visit.position
try$fake.ID <- factor(rep(1:6, rep(5,6)))
xyplot(variable ~ visit.position,
       group=interaction(group, fake.ID)[, drop=TRUE],
       data=try, type="l",
       scales=list(
         at=unique(try$visit.position),
         labels=levels(try$visit)),
       auto.key=TRUE)

xyplot(variable ~ visit.position | group,
       group=fake.ID,
       data=try, type="l",
       scales=list(
         at=unique(try$visit.position),
         labels=levels(try$visit)),
       panel=function(...) {
         panel.abline(v=-10, lty=2, col="gray50")
         panel.superpose(...)
       },
       auto.key=TRUE)


I had some trouble with your email.  It folded at the
column where you said
   class="
   data.frame"
and therefore the class was interpreted as "\ndata.frame",
and was not seen as a "data.frame".

I placed a vertical boundary in the plot between the screening time
and the time=0.

Rich



More information about the R-help mailing list