Re: [R] plotting groupedData object

From: Osman Al-Radi <osman.al.radi_at_gmail.com>
Date: Wed 03 May 2006 - 02:04:18 EST

Dear Deepayan,

Thank you that works very well. What reading material do you recommend to learn the lattice library?

thanks again,

Osman

On 5/2/06, Deepayan Sarkar <deepayan.sarkar@gmail.com> wrote:
> On 5/1/06, Osman Al-Radi <osman.al.radi@gmail.com> wrote:
> > thank your help, here is a simulated data set
> >
> > time<-c(rep(1:10,5))
> > y<-time+rnorm(50,5,2)
> > subject<-c(rep('a',10),rep('b',10),rep('c',10),rep('d',10),rep('e',10))
> > group<-c(rep('A',30),rep('B',20))
> > df<-data.frame(subject,group,time,y)
> > gd<-groupedData(y~time|subject,outer=~group,data=df)
> > plot(gd,outer=T)
> >
> > this produces 2 panels with two lines for group=B, and 3 lines for
> > group=A. Is there a way to add another line to each panel representing
> > the mean at each time point or a lowess curve?
>
> Do you mean ignoring the grouping? That's easier to do if you use
> xyplot directly (which the plot method ultimately calls), e.g.:
>
> xyplot(y ~ time | group, df, groups = subject, type = 'b',
> auto.key = list(lines = TRUE, points = FALSE, columns = 5),
> panel = function(...) {
> panel.linejoin(..., horizontal = FALSE, col = 'black')
> panel.superpose(...)
> })
>
> xyplot(y ~ time | group, df, groups = subject, type = 'b',
> auto.key = list(lines = TRUE, points = FALSE, columns = 5),
> panel = function(...) {
> panel.loess(..., col = 'black')
> panel.superpose(...)
> })
>
> -Deepayan
>

--
Osman O. Al-Radi, MD, MSc, FRCSC
Fellow, Cardiovascular Surgery
The Hospital for Sick Children
University of Toronto, Canada

______________________________________________
R-help@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
Received on Wed May 03 03:17:29 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Wed 03 May 2006 - 04:10:27 EST.

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