[R] layout is to xyplot as ??? is to qplot

hadley wickham h.wickham at gmail.com
Fri Jul 11 00:03:50 CEST 2008


On Thu, Jul 10, 2008 at 3:28 PM, Jim Price <price_ja at hotmail.com> wrote:
>
> Playing with ggplot, something I'd promised myself I'd get around to. I've
> the following scenario:
>
> library(lattice)
> library(ggplot2)
>
> myData <- data.frame(
>        x = rnorm(100),
>        y = rnorm(100),
>        group = 1:4
> )
>
> xyplot(y ~ x | factor(group), data = myData, layout = c(2, 2))
>
> qplot(x, y, facets = ~ group, data = myData)
>
>
>
> In this code the lattice example gives me a 2x2 layout, whereas the ggplot
> example gives me a 1x4 layout, as per the facets specification. Can I mimic
> the effect of the layout parameter in xyplot inside qplot? Apologies if I've
> missed an obvious help-page somewhere!

Not yet, but I'm working on that code at the moment, and it should be
(fingers crossed) included in the next ggplot2 release.  Currently,
ggplot assumes you want a grid of facets defined by separate variables
in the x and y dimensions.

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list