[R] Grouping and stacking bar plot for categorical variables

Simon Kiss sjkiss at gmail.com
Mon Jul 19 15:36:15 CEST 2010


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



More information about the R-help mailing list