Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在下面的数据框中,我希望密度的 y 轴值为 0.6 和 0.4,但它们是 1.0。我觉得我使用..密度的方式显然缺少一些非常基本的东西。但是我的大脑冻结了。我将如何使用 ..density.. 获得所需的行为。任何帮助将不胜感激。
df <- data.frame(a = c("yes","no","yes","yes","no")) m <- ggplot(df, aes(x = a)) m + geom_histogram(aes(y = ..density..))
谢谢,--JT
根据@Arun 的评论:
此刻,yes又no属于不同的群体。为了使它们成为同一组的一部分,请设置分组美学:
yes
no
m <- ggplot(df, aes(x = a , group = 1)) # 'group = 1' sets the group of all x to 1 m + geom_histogram(aes(y = ..density..))