[R] ggplot grouped barchart based on marginal proportions

Crump, Ron R.E.Crump at warwick.ac.uk
Tue Sep 27 12:48:35 CEST 2016


Hi Paul,

Do you want to avoid using prop.table(mtcars_xtab, 1) ?

If not, how about:

ggplot(as.data.frame(prop.table(mtcars_xtab, 1)))+
 geom_bar(aes(x=Var2,y=Freq,fill=Var1), stat="identity", position="dodge")+
 scale_fill_brewer(palette="Set2")


Ron.



More information about the R-help mailing list