Change outlier calculation in Box plot by using ggplot In R
<p>I am trying to customize boxplot, and I was pretty successful except one point. The point that I cannot understand is how I can use stat_summary to show outliers. I have different box plots in one big plot and the outliers do not show on the output. However, if I modify my data and only fed the R with one type of data(only for single box plot) my code works fine and I can see the ourliers crystal clear in the output. I appreciate any help.</p>

<p>Many thanks,</p>

<pre><code>f &lt;- function(x) {r &lt;- c(    quantile(x,probs=c(0.25))-(1.5*(quantile(x,probs=c(0.75))-quantile(x,probs=c(0.25))))     ,quantile(x, probs = c(0.25)), quantile(x, probs = c(0.5)), quantile(x, probs = c(0.75)),     quantile(x,probs=c(0.75))+(1.5*(quantile(x,probs=c(0.75))-quantile(x,probs=c(0.25)))) );names(r) &lt;- c('ymin', 'lower', 'middle', 'upper', 'ymax'); r}
o &lt;-function(x) { print(x); if (length(x) &gt; 7) { pp = subset(x, x &lt; (quantile(x, probs = c(0.25)) - (1.5 * (quantile(x, probs = c(0.75)) - quantile(x, probs = c(0.25))))) | x &gt; (quantile(x, probs = c(0.75)) + (1.5 * (quantile(x, probs = c(0.75)) - quantile(x, probs = c(0.25)))))); return (pp)} else { return (NA)} }

dt=read.table("C:/...../test.txt",header=TRUE,sep=",")
data&lt;-data.frame(x=dt$x,day=dt$day)
dev.new();ggplot(data, aes(x,day)) +   stat_summary(fun.data=f, geom='boxplot')+stat_summary(fun.data =o, geom='point', col='red')#+  stat_summary(fun.y = o2, geom='point', col='red')
</code></pre>