R: How to remove outliers from a smoother in ggplot2?

Have you tried the family = "symmetric" argument to geom_smooth (which will in turn get passed on to loess)? This will make the loess smooth resistant to outliers.

However, looking at your data, why do you think a linear fit is not adequate? You only have 4 x values, and there certainly doesn't seem to be strong evidence for a departure from linearity.


First, I'm not sure an 'outlier' is even properly defined on such small data.

Second, you'd then have to decide what you mean by "outlier" that is, is it one of the drugs, one of the replicates, or one of the time points?

As Hadley notes, there is little evidence of deviation from linearity.

Finally, I think part of the point of using a smoother is that it deals well with outliers, provided there is enough data. But you have very little.

So, I have to ask exactly why you want to remove outliers. That is, what are you going to do with these data (besides making nice plots)?

I hope this helps