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.
在此页面上,他们给出了以下示例
library(ggplot2) library(reshape2) ggplot(data=tips, aes(x=day)) + geom_bar(stat="bin")
我希望在 y 轴上有一个频率,而不是计数。我怎样才能做到这一点?
这是可以在相关问题中找到的解决方案:
pp <- ggplot(data=tips, aes(x=day)) + geom_bar(aes(y = (..count..)/sum(..count..)))
如果您想将频率标记为百分比,请添加以下内容(请参见此处):
library(scales) pp + scale_y_continuous(labels = percent)
现在..prop..可用
..prop..
ggplot(data=tips, aes(x=day)) + geom_bar(aes(y = ..prop.., group = 1))