[R] Surpress one panel in lattice plot..?

Deepayan Sarkar deepayan.sarkar at gmail.com
Tue Aug 25 21:58:41 CEST 2009

On Sun, Aug 23, 2009 at 5:41 PM, Ben Bolker<bolker at ufl.edu> wrote:
> Fredrik Karlsson wrote:
>> Dear list,
>> I have a two character vector with two different values in them (two
>> each, that is). Naturally, when I use these vectors as grouping
>> factors in a lattice plot, I get four panels.
>> Now, one of the possible four combinations will never have data, so
>> one panel will always be empty. So now my question is: can I force R /
>> Lattice not to print it, and give me only the 3 filled panels?
>> I have tried adding "layout=c(3,1)" to the list of arguments, but that
>> gives me one plot that looks like I want it to, and then a new plot
>> with just the empty panel. I use this in an odfWeave document, so just
>> getting the last (empty) plot in the output is not really what I want.
>> I do of course appreciate all the help I can get on this.
> One possibility would be to assign the factor interaction explicitly
> to a variable  (mydata$interact = with(mydata,interaction(f1,f2)) or f1:f2)
> and group by the interaction (which
> will be missing the empty group) rather than by the two groups

In this case, another quick workaround would be to use
layout=c(3,1,1), although that would not easily generalize.


More information about the R-help mailing list