【发布时间】:2017-12-13 17:13:19
【问题描述】:
错误 stat_count() 在 ggplot 可视化中引用什么?
例如,我有以下数据框。
x <- c(1,2,3)
y <- c(1,2,3)
df <- data.frame(x,y)
接下来,我使用 ggplot 和 geom_bar() 绘制它。
ggplot(df, aes(x, y)) +
geom_bar() +
xlab("x") +
ylab("y") +
ggtitle("x and y")
我得到错误:
错误:stat_count() 不得与 y 美学一起使用。
错误stat_count() 在 ggplot 可视化中引用了什么,如何解决它以制作成功的条形图?
谢谢!
【问题讨论】:
-
使用
geom_bar(stat = "identity")。所以stat_count()函数使用aes()中给出的y变量。