On Dec 19, 2010, at 11:23 AM, Dieter Menne wrote:
Dear latticists,
I would like to spread a lattice conditioned plot over multiple pages,
keeping the same layout as if I had only one page as shown in the code
below.
My workaround is to divide the dataframe into subset that fit on one
page,
but the code is ugly.
Is there a build-in way to achieve this?
Dieter
library(lattice)
nsubj = 13 # This number is variable
dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj])
dt$val = rnorm(nrow(dt))
#pdf(file="multpageOk.pdf")
# How it should look:
xyplot(val~time|subj+comp, data=dt,type="l",layout=c(10,3),
subset=as.integer(subj) <= 10)
#dev.off()
# What to do if it stretches over multiple pages, but I want the same
# layout as above?
pdf(file="multpage.pdf")
xyplot(val~time|subj+comp, data=dt,type="l",layout=c(10,3))
dev.off()
What's not working? I see two pages output with "the same layout". The
difference is that in the second case your numbers of groups (subj x
comp) is not an even multiple of your layout numbers, so the 13 subj
levels push 3 of the A's onto the new row of panels and so one.....and
then the second page is partially filled with the 9 remaining "C"'s.
I suppose the fact that I have a default time-stamp for my lattice
output could have some sort of side-effect. In my .Rprofile is this
line:
lattice.options(default.args = list(page = function(n) {
panel.text(lab = sprintf("%s", date()), x = 0.01, y = 0.01, adj =
0, srt=90)
}))
--
David Winsemius, MD
West Hartford, CT
> sessionInfo()
R version 2.12.0 (2010-10-15)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] grid splines stats graphics grDevices utils
datasets methods base
other attached packages:
[1] survey_3.22-4 lubridate_0.2.3 circular_0.4 boot_1.2-43
ggplot2_0.8.8 proto_0.3-8
[7] reshape_0.8.3 plyr_1.2.1 gridExtra_0.7 gdata_2.8.1
Hmisc_3.8-3 survival_2.36-1
[13] sos_1.3-0 brew_1.0-4 lattice_0.19-13
loaded via a namespace (and not attached):
[1] cluster_1.13.2 digest_0.4.2 gtools_2.6.2 stringr_0.4
tools_2.12.0
______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.