[R] ggplot2 - facet_grid and facet_wrap

hadley wickham h.wickham at gmail.com
Sun Nov 23 15:26:06 CET 2008


Hi David,

That looks like a bug!  I'll look into it.

Regards,

Hadley

On Sat, Nov 22, 2008 at 1:07 PM, David Hajage <dhajage.r at gmail.com> wrote:
> Hello R users (and Hadley)
>
> I have another question about ggplot2 :-)
>
> (version 0.8)
>
> `dat` <-
> structure(list(D = c("a", "b", "c", "d"), G = c(1.51520888871520,
> 1.88812208268440, -6.60521862, 0.55968739), E = c(1.38888592256404,
> 1.39366168665589, 1.22509259382058, 1.36617701059296), I =
> c(6.92634958902857,
> 6.94416045215158, 13.2179488828556, 10.1993799972675), B =
> c(7.04367258675502,
> 7.41361056949868, 16.3459547875, 12.968224445), F = c(1.52045742504008,
> 1.51361354379038, 1.77077549933584, 1.64580736760918), A =
> c(2.33837047498186,
> 2.33805720845022, 2.20591935275643, 2.26866576271907), J =
> c(4.33205802184905,
> 4.41713317075078, 11.091251405, 7.21690806), H = c(2.35434145263158,
> 2.35434145263158, 2.00170987368421, 2.26486776842105), C =
> c(6.9118223461127,
> 6.92991088926983, 16.1293054123787, 10.2251608535304)), .Names = c("D",
> "G", "E", "I", "B", "F", "A", "J", "H", "C"), row.names = c(NA,
> 4L), class = "data.frame")
>
> mdat <- melt(dat, id = "D")
>
> qplot(D, value, data = mdat, fill = D, geom = "bar") + facet_grid(~
> variable)
> qplot(D, value, data = mdat, fill = D, geom = "bar") + facet_wrap(~
> variable)
>
>
> The first plot is good, but I think there is a problem in the second plot :
> the barplots are not in the correct order (compare "G" in the first plot and
> in the second plot for example).
>
> I join a pdf file showing the two graphs.
>
> Something is wrong in my code ?
>
> Thank you very much.
>
> david
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>



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



More information about the R-help mailing list