Minimal example using mtcars
- you have to create a data frame with mean for each gear
(in your case it's Name
).
library(tidyverse)
dMean <- mtcars %>%
group_by(gear) %>%
summarise(MN = mean(cyl))
ggplot(mtcars) +
geom_point(aes(mpg, cyl)) +
geom_hline(data = dMean, aes(yintercept = MN)) +
facet_wrap(~ gear)
For your case this should work:
library(tidyverse)
dMean <- UKWinners %>%
group_by(Name) %>%
summarise(MN = mean(TE.Contr.))
ggplot(UKWinners) +
geom_point(aes(Pcode, TE.Contr.)) +
geom_hline(data = dMean, aes(yintercept = MN)) +
facet_wrap(~ Name)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…