Основываясь на предложении @ Kent-Johnson, вот код, который работает.
totals_nonchilled <- CO2 %>%
group_by(Plant, Treatment, .drop = FALSE) %>%
count(Plant) %>% tidyr::spread(key=Treatment, value=n) %>%
mutate(label=paste(nonchilled), Treatment='nonchilled', uptake=45)
totals_chilled <- CO2 %>%
group_by(Plant, Treatment, .drop = FALSE) %>%
count(Plant) %>% tidyr::spread(key=Treatment, value=n) %>%
mutate(label=paste(chilled), Treatment='chilled', uptake=45)
totals <- dplyr::bind_rows(totals_nonchilled, totals_chilled)
graph <- CO2 %>%
ggplot(aes(x=Treatment, y=uptake, fill=Type)) +
geom_violin(width=1) +
facet_wrap(vars(Plant))
graph + scale_y_continuous(limits=c(0, 50), position = "bottom", labels=scales::number) + labs(title= "CO2 dataset : Upate versus Treatment, Type and Plant", x="Treatment", y="Uptake") + scale_colour_discrete(guide = FALSE) +
geom_text(data=totals, aes(Treatment, uptake, label=label),
vjust=0, hjust=0, inherit.aes=FALSE)