I'm struggling to get 4 total geom_hlines on the following plot:
I want LDL cholesterol to have its own mean hline. Here's my code - any suggestions? I think it has to do with my errorbar but I can't figure out how to add LDL cholesterol in.
GAchol <- ggplot(data = df, aes(x=Responder, y=Ncholest, color = "Cholesterol", na.rm = TRUE)) +
geom_jitter() +
geom_jitter(data = df, aes(y=Nldl_cho, color = "LDL Cholesterol")) +
geom_errorbar(
data = df%>% group_by(Responder) %>% summarise(Ncholest = mean(Ncholest)),
aes(x = Responder, ymin = Ncholest, ymax = Ncholest)
) + geom_hline(aes(yintercept = mean(Ncholest)), lty = 2) +
geom_jitter(data = df, aes(y=Nldl_cho, color = "LDL Cholesterol")) +
geom_hline(aes(yintercept = mean(Nldl_cho)), lty = 2) +
theme_bw() +
stat_summary(fun = mean,
geom = "errorbar",
aes(ymax = ..y.., ymin = ..y..),
position = position_dodge(width = 0.8),
width = 0.8
)