boxplots and outliers for more than 6 set of data

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

boxplots and outliers for more than 6 set of data

Hello there,
I am trying to draw boxplot for my data. I wrote a customized function for changing whisker and outliers selection.

I did not get any points as outliers in my data, so after some investigation and some external help from some kind people, I found out the problem,

My code:
rm(list = setdiff(ls(), lsf.str()))
f <- function(x) {r <- 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) <- c("ymin", "lower", "middle", "upper", "ymax"); r}

o <-function(x) {   subset(x,x < (quantile(x, probs = c(0.25)) - (1.5 * (quantile(x, probs = c(0.75)) - quantile(x, probs = c(0.25))))) | x > (quantile(x, probs = c(0.75)) + (1.5 * (quantile(x, probs = c(0.75)) - quantile(x, probs = c(0.25))))))}

data<-data.frame(x=data3$x,day=data3$day);ggplot(data, aes(day,x)) +   stat_summary(, geom='boxplot')+stat_summary(fun.y =o, geom='point',col='red')

As soon as I change the amount of data it would work fine,

Works fine:
datadd=head(data,43*6);ggplot(datadd, aes(factor(day),x,fill=factor(day))) +   stat_summary(, geom='boxplot')+stat_summary(fun.y =o, geom='point',size=1)

but I am getting the following error for the 7th boxplot and later boxplots (or all of my data):

datadd=head(data,43*7);ggplot(datadd, aes(factor(day),x,fill=factor(day))) +   stat_summary(, geom='boxplot')+stat_summary(fun.y =o, geom='point',size=1)
Warning message:
Computation failed in `stat_summary()`:
arguments imply differing number of rows: 1, 0
Any help is highly appreciated.