[R] how do I draw such a barplot?

Ido M. Tamir tamir at imp.univie.ac.at
Mon Jul 16 09:51:02 CEST 2007


Hi,

>Each row represents a single questionnaire with someone giving his 
>agreement/disagreement with a statement (each column is a statement) that is 
>coded from 1 to 5.

Maybe I mixed up columns and rows (because I find only
4 columns in you example) but it would go something like this with ggplot2:

library("reshape")
library("ggplot2")

my.data$id=1:nrow(my.data)
resp <- melt(my.data,id=5)
p <- ggplot(resp, aes(x=factor(variable), fill=factor(value))) + 
geom_bar(position="fill")

http://had.co.nz/ggplot2/position_fill.html

best wishes
ido



More information about the R-help mailing list