title: Annotate ggplot2 facets with number of observations per facet
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2050610/creating-a-facet-wrap-plot-with-ggplot2-with-different-annotations-in-each-plot">Creating a facet_wrap plot with ggplot2 with different annotations in each plot</a><br>
    <a href="https://stackoverflow.com/questions/11458349/add-text-to-a-faceted-plot-in-ggplot2-with-dates-on-x-axis">Add text to a faceted plot in ggplot2 with dates on X axis</a>  </p>
  </blockquote>
  
  
  
  <p>Occasionally when faceting data in ggplot, I think it would be nice to annotate each facet with the number of observations that fell into each facet. This is particularly important when faceting may result in relatively few observations per facet.</p>
  
  <p>What would be the best / simplest way to add an "n=X" to each facet of this plot?</p>
  
  <pre><code>require(ggplot2)
  mms &lt;- data.frame(deliciousness = rnorm(100),
                    type=sample(as.factor(c("peanut", "regular")), 100, replace=TRUE),
                    color=sample(as.factor(c("red", "green", "yellow", "brown")), 100, replace=TRUE))
  
  
  plot &lt;- ggplot(data=mms, aes(x=deliciousness)) + geom_density() + facet_grid(type ~ color)
  </code></pre>