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)
This is the error that appears when I write the above code:
'Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomBar, :object 'brain_mean' not found'
I tried to change many options, such as to insert the option
'inherit.aes = FALSE'
but it seems not to work.
What is my error?