[R] Skipping panels in Lattice
Hanke, Alex
HankeA at mar.dfo-mpo.gc.ca
Thu Sep 9 18:56:23 CEST 2004
I have the same problem. As far as I can see, the only thing you can do is :
attach(df2)
group=paste(facb,facc,sep=" ")
bwplot( dv ~ faca | factor(group))
Alex
-----Original Message-----
From: Leon Barmuta [mailto:Leon.Barmuta at utas.edu.au]
Sent: September 9, 2004 1:19 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Skipping panels in Lattice
Dear all,
I wish to generate a lattice boxplot which skips an empty cell in a design.
I have trawled r-help, scruitinized xyplot(lattice) help page, and merrily
reproduced examples of using skip from a couple of previous r-help queries
and the example given in Pinheiro & Bates. But I must be missing
something...
Here's an example (running R 1.9.1 on Win2k):
# generate some data
df1 <- data.frame(expand.grid(obsnum=seq(1, 15, 1), faca=c("A1", "A2",
"A3"),
facb=c("B1","B2", "B3", "B4"), facc=c("C1","C2")),
dv=rpois(15*3*4*2,10))
# now get rid of the cell B4 & C1 to simulate a missing treatment
combination
df2 <- df1[df1$facb !="B4" | df1$facc !="C1", ]
# plain vanilla lattice plot generates an empty panel corresponding to the
empty cell
plot1 <- bwplot( dv ~ faca | facb*facc, data=df2)
plot1
# now try to skip the empty panel
# turn plot history on so that the separate pages can be recalled
plot2 <- update(plot1, skip=c(rep(F, 3), T, rep(F, 4)))
plot2
and the 4th panel position of the bottom row is skipped, BUT the B4&C1 cell
is shunted to the top left of row 1 and the last panel of plot1 is now
moved to page 2. Messing with layout= doesn't help, neither does
substituting NA for the values of the missing cell (instead of cutting it
out of the data frame). I also get the same behaviour for stripplot and
dotplot too.
Apologies if I've missed a previous solution to this during my searches of
the archive.
Regards,
Leon Barmuta
School of Zoology & TAFI, University of Tasmania, Australia.
______________________________________________
R-help at 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
More information about the R-help
mailing list