title: Ggplot2 plot mean of subset on facet instead global mean
body: <p>I would like to get the facet subet mean (x + y axis) of the subset with ggplot. However, I get the mean of the data and not the subset one. I don't know how to solve this issue.</p>
  
  <pre><code>hsb2&lt;-read.table("http://www.ats.ucla.edu/stat/data/hsb2.csv", sep=",", header=T)
  head(hsb2)
  hsb2$gender = as.factor(hsb2$female)
  
  ggplot() +
    geom_point(aes(y = read,x = write,colour = gender),data=hsb2,size = 2.2,alpha = 0.9) +
    scale_colour_brewer(guide = guide_legend(),palette = 'Set1') +
    stat_smooth(aes(x = write,y = read),data=hsb2,colour = '#000000',size = 0.8,method = lm,formula = 'y ~ x') +
    geom_vline(aes(xintercept = mean(write)),data=hsb2,linetype = 3) +
    geom_hline(aes(yintercept = mean(read)),data=hsb2,linetype = 3) +
    facet_wrap(facets = ~gender)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/R5NEB.png" alt="enter image description here"></p>