r - Not understanding the behavior of ..density -


in dataframe below, expect y axis values density 0.6 , 0.4, yet 1.0. feel there extremely basic missing way using ..density.. brain freezing. how obtain desired behavior using ..density.. appreciated.

df <- data.frame(a = c("yes","no","yes","yes","no")) m <- ggplot(df, aes(x = a)) m + geom_histogram(aes(y = ..density..)) 

enter image description here

thanks, --jt

as per @arun's comment:

at moment, yes , no belong different groups. make them part of same group set grouping aesthetic:

m <- ggplot(df, aes(x = , group = 1))   # 'group = 1' sets group of x 1 m + geom_histogram(aes(y = ..density..))  

Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -