[R] xyplot plot with groups

Deepayan Sarkar deepayan.sarkar at gmail.com
Sat Aug 21 08:31:19 CEST 2010


On Fri, Aug 20, 2010 at 4:03 PM, array chip <arrayprofile at yahoo.com> wrote:
> What a simple way to do what I want to do! Thanks.
>
> But if there is missing data in variable "y", then the averaged lines is broken
> where the missing data is present. For example:
>
> dat$y[c(10,185,200,400,450)]<-NA
>
> then using type='a' option will result in broken lines.
> xyplot(y~day|sex, groups=trt, data=dat, type=c('p','g', 'a'))
>
> I was able to solve this using panel.superpose() and panel.average(). But it's
> too much syntax. Is there a simpler way to do this?

Omit the NA rows from your dataset beforehand: e.g.,

xyplot(y~day|sex, groups=trt, data=na.omit(dat), type=c('p','g', 'a'))

or

xyplot(y~day|sex, groups=trt, data=dat[!is.na(dat$y), ], type=c('p','g', 'a'))

-Deepayan



More information about the R-help mailing list