0基础学习R语言,目前学习R for data science这本书。
想将书中例子bar图按百分比显示,并填充不同颜色。结果图形没有填充颜色,代码及提示如下:
ggplot(data = diamonds) +
geom_bar(mapping = aes(x = cut, y = stat(prop), group = 1, fill = cut))
Warning message:
The following aesthetics were dropped during statistical transformation: fill
ℹ This can happen when ggplot fails to infer the correct grouping structure
in the data.
ℹ Did you forget to specify agroup
aesthetic or to convert a numerical
variable into a factor?
应该如何修改,谢谢!