相关疑难解决方法(0)

R ggplot2:stat_count()不得与条形图中的美学错误一起使用

嗨伙计们,我在绘制条形图时遇到此错误,我无法摆脱它,我已经尝试了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()
Run Code Online (Sandbox Code Playgroud)

错误:

  stat_count() must not be used with a y aesthetic
Run Code Online (Sandbox Code Playgroud)

data_country中的数据

    country conversion_rate
    <fctr>           <dbl>
  1   China     0.001331558
  2 Germany     0.062428188
  3      UK     0.052612025
  4      US     0.037800687
Run Code Online (Sandbox Code Playgroud)

错误来自条形图而不是虚线图表.任何建议都会有很大帮助

r bar-chart ggplot2

73
推荐指数
3
解决办法
18万
查看次数

标签 统计

bar-chart ×1

ggplot2 ×1

r ×1