Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Some sample data
- set.seed(0)
- x <- rexp(100, 1/5)
- ## Default boxplot
- boxplot(x)
- abline(h=quantile(x, probs=c(0.02, 0.98)), col="blue", lty=2) # add your quantiles
- ## Copy the function and change the stat-calculating part of its body
- mybox <- boxplot.default
- body(mybox)[[10]] <- quote(
- for (i in 1L:n) {
- bstats <- boxplot.stats(unclass(groups[[i]]), range)
- bstats$stats[c(1,5)] <- quantile(unclass(groups[[i]]), probs=c(0.02, 0.98))
- groups[i] <- list(bstats)
- }
- )
- ## Now, use it and compare
- mybox(x)
- abline(h=quantile(x, probs=c(0.02, 0.98)), col="blue", lty=2) # add your quantiles
Advertisement
Add Comment
Please, Sign In to add comment