[R] Grouping and stacking bar plot for categorical variables

2010-07-19 Thread Simon Kiss

Hi all,
I have a series of cateogiral variables that look just like this:

welfare=sample(c(less, same, more), 1000, replace=TRUE)
education=sample(c(less, same, more), 1000, replace=TRUE)
defence=sample(c(less, same, more), 1000, replace=TRUE)
egp=sample(c(salariat, routine non-manual, self-employed,  
farmers, skilled labour, foremen, unskilled labour, social and  
cultural specialists), 1000, replace=TRUE)


welfare, education and defence are responses to a series of questions  
about whether or not the respondent supports, less, the same or more  
spending on an issue.


egp is a class category.

What I would like is a barplot that is both stacked and grouped.  The  
x-axis categories should be the egp class category.  Within each class  
category I would like a cluster of stacked bars that show the  
distribution of spending support for each issue.


Can anyone suggest something?
Yours, Simon Kiss

*
Simon J. Kiss, PhD
SSHRC and DAAD Post-Doctoral Fellow
John F. Kennedy Institute of North America Studies
Free University of Berlin
Lansstraße 7-9
14195 Berlin, Germany
Cell: +49 (0)1525-300-2812,
Web: http://www.jfki.fu-berlin.de/index.html

__
R-help@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.


Re: [R] Grouping and stacking bar plot for categorical variables

2010-07-19 Thread David Winsemius


On Jul 19, 2010, at 9:36 AM, Simon Kiss wrote:


Hi all,
I have a series of cateogiral variables that look just like this:

welfare=sample(c(less, same, more), 1000, replace=TRUE)
education=sample(c(less, same, more), 1000, replace=TRUE)
defence=sample(c(less, same, more), 1000, replace=TRUE)
egp=sample(c(salariat, routine non-manual, self-employed,  
farmers, skilled labour, foremen, unskilled labour, social and  
cultural specialists), 1000, replace=TRUE)


welfare, education and defence are responses to a series of  
questions about whether or not the respondent supports, less, the  
same or more spending on an issue.


egp is a class category.

What I would like is a barplot that is both stacked and grouped.   
The x-axis categories should be the egp class category.  Within each  
class category I would like a cluster of stacked bars that show the  
distribution of spending support for each issue.


Can anyone suggest something?


Learn to search:

RSiteSearch(stacked barchart)

Once you are there you can also ask for prior years' r-help searching  
which will provide a large number of worked examples since this has  
been a frequently asked (and answered) question.


--
David.


Yours, Simon Kiss

*
Simon J. Kiss, PhD
SSHRC and DAAD Post-Doctoral Fellow
John F. Kennedy Institute of North America Studies
Free University of Berlin
Lansstraße 7-9
14195 Berlin, Germany
Cell: +49 (0)1525-300-2812,
Web: http://www.jfki.fu-berlin.de/index.html

__
R-help@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
West Hartford, CT

__
R-help@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.