[R] multiple pages with ggplot2 facet_wrap?
Bill Gillespie
billg at metrumrg.com
Thu Oct 29 02:19:28 CET 2009
I currently use lattice functions to produce multiple pages of plots
using the "layout" argument to specify the number of rows and columns
of panels, e.g.,
xyplot(price ~ carat | clarity, diamonds, layout = c(2, 2))
This results in 2 pages of 4 panels each. "diamonds" is a data.frame
distributed with ggplot2.
I would like to do the same with ggplot2 but have been unsuccessful.
The following sequence of statements seemed like a logical way to do it:
p <- ggplot(diamonds, aes(carat, price))
p + geom_point() + facet_wrap(~clarity, ncol = 2, nrow = 2)
But they result in the error statement: "Error in nrow * ncol : non-
numeric argument to binary operator".
Is facet_wrap or facet_grid capable of producing multiple pages of
plots and, if so, how?
Thanks,
Bill
William R Gillespie, VP Strategic Modeling & Simulation
Metrum Research Group LLC
2 Tunxis Road, Suite 112, Tariffville, CT 06081
Direct & FAX:919-371-2786, Main:860-735-7043
billg at metrumrg.com
www.metrumrg.com
More information about the R-help
mailing list