par(mfrow)
.
n2mfrow(nr.plots)
nr, nc
giving the number of rows
and columns, fulfilling nr >= nc >= 1
and nr * nc >= nr.plots
.
par
, layout
.require(graphics)
n2mfrow(8) # 3 x 3
n <- 5 ; x <- seq(-2, 2, len = 51)
## suppose now that 'n' is not known {inside function}
op <- par(mfrow = n2mfrow(n))
for (j in 1:n)
plot(x, x^j, main = substitute(x^ exp, list(exp = j)), type = "l",
col = "blue")
sapply(1:10, n2mfrow)
Run the code above in your browser using DataLab