I am using the ggplot2 library in R.
Suppose I have a graph that looks like this:
library(ggplot2)
ggplot(work) + geom_line(aes(x = var1, y = var2, group = 1)) +
theme(axis.text.x = element_text(angle = 90)) +
ggtitle("sample graph")
Is there a way to directly add a second line to this graph?
e.g.
ggplot(work) + geom_line(aes(x = var1, y = var2, group = 1)) +
geom_line(aes(x = var1, y = mean(var2), group = 1)) +
theme(axis.text.x = element_text(angle = 90)) +
ggtitle("Sample graph")
Thanks


)- it seems to work with edits above. As suggested by @Ronak Shah, please supply MRE if it still doesn't work as you'd likegeom_hline(yintercept = mean(var2))?