Want facet_wrap to have different parameters for each plot. Example below:
x = c(43,22,53,21,13,53,23,12,32)
y = c(42,65,23,45,12,22,54,32,12)
df = cbind(x,y)
df = as.data.frame(df)
meany = mean(y)
p = ggplot(df, aes(x=x,y=y, colour=(y > meany))) +
geom_point() +
geom_hline(yintercept = meany)
p
That works fine, there is a line at mean of y and the points are different colors above and below the line.
I have a larger data frame where I want to do this to each factor level and use facet_wrap to show all the plots. I am not sure how to get the colour and yintercept in ggplot to change for every graph in facet_wrap.
Also, I want the plot to have more layers, i.e. each plot will be comparing MSE of different models.
Thanks for the help.