Re: [R] plotting groupedData object

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue 02 May 2006 - 14:52:58 EST

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



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 Tue May 02 14:57:20 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.