我正在学习r4ds第3.7节中的geom_bar.有新西兰公司.我运行的代码如下:
library(ggplot2)
ggplot(data = diamonds) + geom_bar(mapping = aes(x = cut, y = ..prop.., group = 1))
然后我有了这个情节:
关键是,如果我排除"group=1"部分:
library(ggplot2)
ggplot(data = diamonds) + geom_bar(mapping = aes(x = cut, y = ..prop..))
绘图将是错误的,
但如果我将group=1替换为group=2或group="x",则绘图看起来仍然正确.所以我不太明白这里group=1的含义以及如何使用它.