How do you create a faceted plot using ggplot2 where each facet is plotted if and only if the number of observations in the facet exceeds some specified threshold? This question explores how to annotate each facet with the number of observations in the facet, but I'd like to be able to specify a threshold where every facet that has fewer observations than the threshold is not plotted at all.
Here is a straightforward example of the type of plot that I'd like to specify the threshold for:
require(ggplot2)
p <- ggplot(data,aes(x=xaxis)) + geom_density()
p <- p + facet_grid(ab1 ~ ab2)
This produces a faceted plot where some facets have too few observations to be meaningful, so I'd like an empty grid/space there instead of plotting misleading data.