Re: [R] stacked bar plot

From: Ista Zahn <izahn_at_psych.rochester.edu>
Date: Tue, 22 Mar 2011 13:10:02 +0000

Hi Chandra,
You could use ggplot2:

library(ggplot2)
ggplot(dat, aes(Group_size, Number, fill=Sex)) +   geom_bar(stat="summary", fun.y="mean")

Best,
Ista

On Tue, Mar 22, 2011 at 7:30 AM, Chandra Salgado Kent <C.Salgado_at_cmst.curtin.edu.au> wrote:
> Hello,
>
>
>
> I'm wondering if someone may be able to help me, and do apologize if there is a simple and obvious solution for this. I am somewhat new to R, and have been searching for a simple solution for a couple of days.
>
>
>
> I am interested in finding a tool that allows me to plot a stacked bar plot.
>
>
>
> My data set is in the following format:
>
> data<-data.frame(Sex=c("M","F","M","F","F"), Number=c(10,3,1,2,3), Group_size=c(1,1,2,2,2))
>
>
>
> I would like to have the factor "Sex" stacked, "Group size" as a Factor on the X axis, and "Number" on the Y axis (summed so that there is only one value for each Sex by Group_size combination).
>
>
>
> Many, many thanks for any help you may be able to offer!
>
>
>
> Chandra
>
>
>        [[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.
>

-- 
Ista Zahn
Graduate student
University of Rochester
Department of Clinical and Social Psychology
http://yourpsyche.org

______________________________________________
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.
Received on Tue 22 Mar 2011 - 13:18:54 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 22 Mar 2011 - 14:40:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive