[R] adding to Trellis plots

Andrew C. Ward s195404 at student.uq.edu.au
Thu Aug 14 00:36:58 CEST 2003


Dear Dassy,

I'm not entirely sure of the specifics of what you want to
achieve, but for similar sounding things I typically make
use of the subscripts argument to panel functions. Check out
the following simple example.

   x <- rnorm(500)
   y <- 0.9*x + sqrt(1-0.9*0.9)*rnorm(500)
   g <- sample(x=LETTERS[1:3], size=500, replace=TRUE)
   a <- rnorm(500)
   tmp <- data.frame(x=x, y=y, a=a, subject=g)
   #
   xyplot(y ~ x | subject, data=tmp, panel=function
(x,y,subscripts=subscripts,m=a,...) {
      panel.xyplot(x,y,...)
      panel.abline(h=max(m[subscripts]))
   }, key=list(space="top", lines=list(lty=1), text=list
("Maximum")))


Regards,

Andrew C. Ward

CAPE Centre
Department of Chemical Engineering
The University of Queensland
Brisbane Qld 4072 Australia
andreww at cheque.uq.edu.au


Quoting "Brunschwig, Hadassa {PDMM~Basel}" 
<HADASSA.BRUNSCHWIG at Roche.COM>:

> Hello everyone
> 
> I have data grouped by subjects and i used the trellis
> plot to show the curve for each subject. I have another
> vector "a" which gives me the highest points the curves
> for each subjects can achieve ( the curve is exponential
> ). Now i want to draw a horizontal line, whose values are
> saved in "a", on each plot for each subject. Is there any
> possibility to do that? Obviously i should use something
> like panel.abline, the problem is how i can inform R that
> each value in "a" is a horizontal line for each plot.
> 
> Thanks a lot for answers.
> 
> Dassy
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
>




More information about the R-help mailing list