我在绘制条形图时遇到此错误,但我无法摆脱它,我尝试了qplot和ggplot,但仍然是相同的错误。
以下是我的代码:
library(dplyr)
library(ggplot2)
#Investigate data further to build a machine learning model
data_country = data %>%
group_by(country) %>%
summarise(conversion_rate = mean(converted))
#Ist method
qplot(country, conversion_rate, data = data_country,geom = "bar", stat ="identity", fill = country)
#2nd method
ggplot(data_country)+aes(x=country,y = conversion_rate)+geom_bar()
错误:
stat_count() must not be used with a y aesthetic
data_country中的数据:
country conversion_rate
<fctr> <dbl>
1 China 0.001331558
2 Germany 0.062428188
3 UK 0.052612025
4 US 0.037800687
错误出现在条形图中,而不出现在虚线图中。