I need to add mean or median to a bar plot, don't know why it doesn't work:
data_GP %>%
group_by(Customer, Year, Customer_category) %>%
dplyr::summarise(GP_value = mean(GP),
REV_value = mean(REV),
GP_percent = mean(GP)/mean(REV)) %>%
filter(., GP_percent > -1, Customer_category == "regular", Year == 2019) %>%
ggplot(.,aes(x = Customer, y = GP_value)) +
stat_summary(fun.y=mean, geom="line") +
geom_bar(alpha = 0.5, stat = "identity")
So, basically I would like to show one line on a geom_bar showing mean (or median) value for all observations. Error comes up and goes:
geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?