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

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -