[R] Sweave with layout() and loop

Mikkel Grum mi2kelgrum at yahoo.com
Sun Jun 26 20:36:14 CEST 2005


When I try the following code with the Windows
graphics window, a new window is opened for each
multiple of four images I produce.

par(layout(matrix(c(1,2,3,4), 2, 2, byrow = TRUE)),
mar = c(2, 3, 2, 3))

for (i in 1:n) {
 image(... )
 }

When I try to do the same with Sweave to produce a pdf
document, I only get one graphic with the first four
graphs.  How do I get the rest when n is greater than
four?

<<Plots, fig=TRUE, eps=FALSE, echo=FALSE,   
results=hide, width=6.8, height=9.8>>=

par(layout(matrix(c(1,2,3,4), 2, 2, byrow = TRUE)),
mar = c(2, 3, 2, 3))

for (i in 1:n) {
 image(... )
 }

Any ideas?
cheers,
Mikkel




More information about the R-help mailing list