[R] (Grouped + Stacked) Barplot

Greg Snow Greg.Snow at imail.org
Thu Dec 3 17:50:42 CET 2009


A bar graph including both stacked and grouped bars will put lots of pretty colors on the page and probably be eyecatching, but is unlikely to be the most effective way to convey the actual meaning of the data.  I would recommend that you explore other possibilities for doing the plot.  A dot plot may give you what you want, see the dotchart2 function in the Hmisc package or the dotplot function in the lattice package.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Xin Ge
> Sent: Wednesday, December 02, 2009 8:25 PM
> To: r-help at r-project.org
> Subject: [R] (Grouped + Stacked) Barplot
> 
> Hi All,
> 
> I have googled and tried finding if someone has ever tried producing
> (Grouped + Stacked) Barplot. I couldn't find one.
> 
> My data needs to be reshaped, but once it is done it would be something
> like
> this:
> 
> Factor1    Factor2    Factor3    Value
> A    X    P    10
> A    X    Q    20
> A    Y    P    20
> A    Y    Q    5
> A    Z    P    20
> A    Z    Q    10
> B    X    P    20
> B    X    Q    10
> B    Y    P    30
> B    Y    Q    50
> B    Z    P    10
> B    Z    Q    20
> 
> There are three categorical variables (Factor1, Factor2, and Factor3
> having
> 2,3, and 2 levels resp.). I'm trying to plot "Factor1" on x axis --
> each
> level of this factor should have three (grouped) bars (one for each
> level of
> Factor2). Which will further be stacked by each level of Factor3.
> 
> Can anyone guide me please, thanks,
> ~Xin
> 
> 	[[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