[R] Trellis, conditioning on more than 2 variables,

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Oct 14 00:58:23 CEST 2008


On Mon, Oct 13, 2008 at 3:38 PM, erwann rogard <erwann.rogard at gmail.com> wrote:
> hello,
>
> i need help with:
>
> data$f1<-as.factor(data$f1)
> data$f2<-as.factor(data$f2)
> s3<-equal.count(data$s2,number=3)
> densityplot(~y| f1 + f2 + s3,
>   data=mydata
> )
>
> this produces 3 plots, *successively*, one for each value of s3. i was
> hoping it would produce one plot. is trellis limited to 2 conditional
> variables? if not, what are the appropriate commands?

The default layout uses multiple pages for 3 or more conditioning
variables. If you want to get them on a single page, you need to
specify the layout as c(ncol, nrow), e.g.,

densityplot(~y| f1 + f2 + s3, data=mydata, layout = c(5, 4))

Alternatively, if you just want to specify the number of panels per
page, and want the details to be computed automatically (as with one
conditioning variable), you can do

densityplot(~y| f1 + f2 + s3, data=mydata, layout = c(0, 20))

?xyplot has details.

-Deepayan



More information about the R-help mailing list