[R] Grouped Boxplot

Petr PIKAL petr.pikal at precheza.cz
Thu Nov 26 06:31:09 CET 2009


Hi

r-help-bounces at r-project.org napsal dne 24.11.2009 18:44:43:

> Back in March Soren Vogel asked exactly the same thing:
> 
> Here is the solution that was offered then. (He offered a dataset as 
> requested in the Posting Guide.)  ... with only a minor adjustment:
> 
> 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")))
> boxplot( val ~ g + G2, data=dta, at = 0.8*c(1,2,3,4,6,7,8,9), 
> boxwex=0.8)
> 
> This should have shown up with this:
> 
> RSiteSearch("grouped boxplot")

or ggplot2 variant

p <- ggplot(dta, aes(factor(G2), val))
p + geom_boxplot(aes(fill = factor(g)))

Regards
Petr


> 
> -- 
> David
> 
> On Nov 24, 2009, at 10:35 AM, Gary wrote:
> 
> > Thanks Uwe and Petr for your suggestion. Please see Fig. 3 on the 
> > attached
> > file. Thanks!
> >
> > On Tue, Nov 24, 2009 at 6:44 AM, Petr PIKAL <petr.pikal at precheza.cz> 
> > wrote:
> >
> >> Hi
> >>
> >> try ggplot2. It has some functionality to make groups of boxplots.
> >>
> >> Regards
> >> Petr
> >>
> >>
> > Your attachment did not pass the list's filters. Anyway, see ?boxplot.
> >
> > Uwe Ligges
> >
> >
> >
> >>
> >> r-help-bounces at r-project.org napsal dne 24.11.2009 03:33:49:
> >>
> >>> Hi R Users,
> >>>
> >>> I'm interested in plotting a grouped boxplot (please see attached 
> >>> file
> >> for
> >>> sample). Can anyone suggest a function{package} which can help me
> >> achieve
> >>> this.
> >>>
> >>> Thanks,
> >>> Gary
> >>> ______________________________________________
> >>> 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.
> >>
> >>
> > <GroupedBoxplot.pdf>______________________________________________
> > 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.
> 
> David Winsemius, MD
> Heritage Laboratories
> West Hartford, CT
> 
> ______________________________________________
> 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