[R] ggplot2 / lattice

Gabor Grothendieck ggrothendieck at gmail.com
Fri Dec 18 04:09:36 CET 2009


Try this:

bwplot(val ~ g | G2, dta)


On Thu, Dec 17, 2009 at 9:34 PM, Gary Miller <mail2garymiller at gmail.com> wrote:
> Hi R Users,
>
> Is there a equivalent function for the following R code in Lattice package.
> I want to plot a grouped box plots (grouped by two factors).
>
> g <- rep.int(c("A", "B", "C", "D"), 125)
> t <- rnorm(5000)
> a <- sample(t, 500, replace=TRUE)
> b <- sample(t, 500, replace=TRUE)
> dta <- data.frame(val = sample(t,1000), g = gl(4, 250, labels=c("A", "B",
> "C", "D")) , G2 = gl(2,1, labels=c("XX", "YY")))
> # ggplot2 package required
> p <- ggplot(dta, aes(factor(G2), val))
> p + geom_boxplot(aes(fill = factor(g)))
>
> Any suggestion would be highly appreciated!
> Gary
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>




More information about the R-help mailing list