title: Add a number of observations per group AND SUBGROUP in ggplot2 boxplot
body: <p>This might seem like a duplicate of <a href="https://stackoverflow.com/questions/15660829/how-to-add-a-number-of-observations-per-group-and-use-group-mean-in-ggplot2-boxp/15661466#comment57381365_15661466">this question</a>, but in fact I want to expand the original question.</p>
  
  <p>I want to annote the boxplot with the number of observations per group AND SUBGROUP in ggplot. Following the example or the original post, here is my minimal example:</p>
  
  <pre><code>require(ggplot2)
  
  give.n &lt;- function(x){
    return(c(y = median(x)*1.05, label = length(x))) 
    # experiment with the multiplier to find the perfect position
  }
  
  ggplot(mtcars, aes(factor(cyl), mpg, fill = factor(gear))) +
    geom_boxplot() +
    stat_summary(fun.data = give.n, geom = "text", fun.y = median)
  </code></pre>
  
  <p>My problem is that the number of samples all line up in the center of the group, rather than plotting on the appropriate boxplot (as the picture below shows):<a href="https://i.stack.imgur.com/l5lkg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l5lkg.png" alt="Annotes are centering in the middle of the group rather than plotting on the appropriate boxplot"></a></p>