[R] Grouping and stacking bar plot for categorical variables
Jim Lemon
jim at bitwrit.com.au
Tue Jul 20 10:55:46 CEST 2010
On 07/19/2010 11:36 PM, 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?
Hi Simon,
You might also like to look at the barNest function in the plotrix
package, not stacked, but nested.
Jim
More information about the R-help
mailing list