图层错误(数据=数据,映射=映射,统计=统计,geom = GeomBar 、:找不到对象

时间:2019-03-02 10:38:22

标签: r ggplot2

msleep %>%
  group_by(vore) %>%
  na.omit() %>% 
  summarise(length_mean = mean(sqrt(bodywt)),
            brain_mean = mean(sqrt(brainwt))) %>%

  ggplot(aes(vore, length_mean, fill=vore)) +
  geom_bar(stat = 'identity', width = brain_mean) + 
  scale_fill_brewer(palette = 'Blues')+
  coord_flip() + 
  scale_x_discrete(limits = c("herbi", "carni", "omni", 'insecti')) +   
  ggtitle('avarage of the mean by sex') + 
  geom_text(aes(label = (round(length_mean, 3))), 
            vjust = 0.5, hjust = 1.1, color = "black", size = 3.5)

这是我编写上面的代码时出现的错误:

  

“图层错误(数据=数据,映射=映射,统计=统计,geom = GeomBar ,:找不到对象'brain_mean''

我试图更改许多选项,例如插入选项

'inherit.aes = FALSE'

但似乎不起作用。

我的错误是什么?

0 个答案:

没有答案