I'm plotting a group of curves, using facet in ggplot2. I'd like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I'd like to stop the plot failing when one of the panels only has 1 or 2 points.
Example:
a <- data.frame( x=1:100, y=sin(seq(0.1,10,0.1) ))
b <- data.frame( x=1:5, y=sin(seq(0.1,0.2,0.1) ))
l <- melt(list(a=a,b=b),id.vars="x")
qplot( x, value, data=l ) + geom_smooth() + facet_wrap( ~ L1 )