Hello, Thanks for your suggestion. It works in my simplified example. However, it didn't work in my real code. It is probably because I neglected to include the group argument in the example. I apologize for that.
Below is the real code, if you need the actual data I can include it too. # this works well xyplot(PaCO2~time|group, group=animal,layout=c(3,1,1),aspect=1, panel=function(...){ panel.loess(...) panel.superpose(...)} ,data=pig,subset=time>5 & time<181, xlab='Time (minutes)', ylab='PaCO2 (mmHg)') # this gives the following error "Error in using packet 1 data, X argument missing with no #default" in each of the plot panel xyplot(PaCO2~time|group, group=animal,layout=c(3,1,1),aspect=1, panel=function(x,y,subscripts,...){ panel.loess(...) panel.superpose(...) panel.text(100,110,label=c(' ','p=0.007','p=0.006')[tail(subscripts, 1)])} ,data=pig, subset=time>5 & time<181, xlab='Time (minutes)', ylab='PaCO2 (mmHg)') Thanks tremendously for your help. I don't know why its soo hard just to add some text! Osman Osman O. Al-Radi, MD, MSc, FRCSC Staff Cardiovascular Surgeon Co-medical director, Tissue Bank The Hospital for Sick Children University of Toronto, Canada On Thu, Sep 24, 2009 at 2:18 PM, Henrique Dallazuanna <www...@gmail.com>wrote: > Try this: > > xyplot(y ~ x | a, > panel=function(x, y, subscripts, ...){ > panel.loess(x, y) > panel.text(0, 2, > label=c('best','better','bad','worst')[tail(subscripts, 1)/100]) > }) > > On Thu, Sep 24, 2009 at 2:45 PM, Osman Al-Radi <osman.al.r...@gmail.com> > wrote: > > Dear R-help, > > > > I would like to add text to each of four panels in a plot generated by > > xyplot in lattice library. A sample code is given below, the plot > generated > > has the first label repeated in all panels! > > > > How can I get the labels to be different in each panel? > > > > library(lattice) > > x <- rnorm(400) > > y <- rnorm(400) > > a <- gl(4, 100) > > > > xyplot(y~x|a, > > panel=function(...){ > > panel.loess(...) > > panel.text(0,2,label=c('best','better','bad','worst'))}) > > > > Thanks > > > > Osman > > > > > > > > Osman O. Al-Radi, MD, MSc, FRCSC > > Staff Cardiovascular Surgeon > > Co-medical director, Tissue Bank > > The Hospital for Sick Children > > University of Toronto, Canada > > > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-help@r-project.org 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. > > > > > > -- > Henrique Dallazuanna > Curitiba-Paraná-Brasil > 25° 25' 40" S 49° 16' 22" O > [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org 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.