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..))
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
Post a Comment