can anybody answer how I can plot a bar-plot which maps a numeric x-variable to its relative frequency grouped by a factor in ggplot2? The important thing is: The relative frequ
I was facing the same problem as yours and I figured it out: instead of plotting ..count../sum(..count..)
, plot ..density..*your_binwidth
Indeed, the ..density..
variable created by the bin stat is basically equal to proportion/bindwidth.
Your code becomes:
p + stat_bin(aes(y=..density..*0.2), position='dodge', binwidth=0.2)