[R] Layout of mulitpage conditioned lattice plots

Dieter Menne dieter.menne at menne-biomed.de
Sun Dec 19 20:26:13 CET 2010


Here is an example with ggplot2, which can also be used in a similar way with
lattice. Again, the last page is the problem: the arrangement is correct
here, but the last page (with 1 instead of 5 plots) has a different panel
size which makes a comparison difficult.

And, since I have much more points per panel: ggplot2 is slow compared to
lattice.

Dieter

library(ggplot2)
nsubj = 11
dt = expand.grid(time=1:20,comp=LETTERS[1:3],subj=letters[1:nsubj])
dt$val = rnorm(nrow(dt))
nPerPage = 5
for (i in seq(1,nsubj,by=nPerPage)) {
  subjs = i:max(i+nPerPage-1,nPerPage)
  print(subjs)
  p = qplot(time,val,data=subset(dt,as.integer(subj) %in% subjs )) +
    geom_line()+ facet_grid(comp ~ subj)+opts(aspect.ratio=1)
  print(p)
}

-- 
View this message in context: http://r.789695.n4.nabble.com/Layout-of-mulitpage-conditioned-lattice-plots-tp3094581p3094775.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list