Try this and see the comment from @JakeKaupp below.
library(tidyverse)
class <- mpg %>%
count(class) %>%
mutate(label = paste0("n = ", n))
ggplot(data = mpg, aes(class, hwy)) +
geom_jitter(width = 0.1) +
stat_summary(geom = "point", fun.y = mean, colour = "red", size = 5) +
geom_text(data = class, aes(y = 10, label = label))
source
share