我正在尝试创建以下图,但在y轴上具有比例。
library(ggplot2)
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, fill = clarity), position = "dodge")
但是当我添加y=..prop..
时,它不会按clarity
进行分组。我尝试了以下方法:
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, y = ..prop.., fill = clarity), position = "dodge")