[R] ggplot2 multiple group barchart
    Waller Gregor (wall) 
    wall at zhaw.ch
       
    Wed Sep  1 17:15:52 CEST 2010
    
    
  
hi there.. i got a problem with ggplot2.
here my example:
library (ggplot2)
v1  <- c(1,2,3,3,4)
v2  <- c(4,3,1,1,9)
v3  <- c(3,5,7,2,9)
gender <- c("m","f","m","f","f")
d.data  <- data.frame (v1, v2, v3, gender)
d.data
x  <- names (d.data[1:3])
y  <-  mean (d.data[1:3])
pl  <- ggplot (data=d.data, aes (x=x,y=y))
pl  <- pl + geom_bar()
pl  <- pl + coord_flip()
pl  <- pl + geom_text (aes(label=round(y,1)),vjust=0.5,
hjust=4,colour="white", size=7)
pl
this gives me a nice barchart to compare the means of my variables
"v1","v2" and "v3".
my question: how do i have to proceed if i want this barchart splittet
by the variable "gender".
so i get two small bars for "v1", one for female and one for male, two
bars for "v2" etc. 
i need them all in one chart. 
fill=gender, position="dodge" do not work... 
any ideas?
thanks a lot
greg
    
    
More information about the R-help
mailing list