Skip to content
Prev 79385 / 398502 Next

Range plots (lattice or base?)

I have gotten what I want by following Deepayan's advice. I have written
the following replacement for boxplot.stats. When I run bwplot, I get
exactly what I want. This function is lacking sufficient error checking
but here it is. The bootstrapping makes it a bit slow. What I would like
to do is write a new function (ciplot) that stores the original
boxplot.stats fucntion, replaces it with my new stats function, calls
bwplot, and then return boxplot.stats to its original.


boxplot.stats <-function (x,coef = 1.5, do.conf=TRUE, do.out=TRUE) {
Mean <- mean(x,na.rm = TRUE)
Sd <- sd(x,na.rm = TRUE)
lp <- (quantile(x,0.10, na.rm = TRUE)[[1]])
up <- (quantile(x,0.90, na.rm = TRUE) [[1]])
sizen <- sum(!is.na(x))
lci <- 0
uci <- 0
if (sizen > 5)
 {CI <- try((boot.ci(boot(x, function(x,i) mean(x[i]), R = 5000)
           ,conf = c(0.95),
           type = c("norm")))$normal[-1])
 lci <- CI[1]
 uci <- CI[2]}
lconf <- 0
uconf <- 0
stats <- c(lp,lci,Mean,uci,up)
n<-sizen
conf <-c(lconf,uconf)
result <- list(stats = stats,n=n,conf=conf,out = NA)
return(result)
}