Guest User

Untitled

a guest
Aug 11th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. ## Some sample data
  2. set.seed(0)
  3. x <- rexp(100, 1/5)
  4.  
  5. ## Default boxplot
  6. boxplot(x)
  7. abline(h=quantile(x, probs=c(0.02, 0.98)), col="blue", lty=2) # add your quantiles
  8.  
  9. ## Copy the function and change the stat-calculating part of its body
  10. mybox <- boxplot.default
  11. body(mybox)[[10]] <- quote(
  12. for (i in 1L:n) {
  13. bstats <- boxplot.stats(unclass(groups[[i]]), range)
  14. bstats$stats[c(1,5)] <- quantile(unclass(groups[[i]]), probs=c(0.02, 0.98))
  15. groups[i] <- list(bstats)
  16. }
  17. )
  18.  
  19. ## Now, use it and compare
  20. mybox(x)
  21. 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