[R] Boxplot BUT with Mean, SD, Max & Min ?

Vining, Kelly Kelly.Vining at oregonstate.edu
Mon Sep 26 18:44:58 CEST 2011


You can also eliminate the outliers from boxplots with the "outline=F" parameter.

--Kelly V. 

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of William Dunlap
Sent: Monday, September 26, 2011 8:12 AM
To: phil at pricom.com.au
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Boxplot BUT with Mean, SD, Max & Min ?

If you draw the whiskers out to the extrema of the data you may wish to omit the "outliers", which are encoded by the out and group components of boxplot's return value:

 d <- split(Nile, factor(time(Nile)>1902, labels=c("pre-dam", "post-dam")))
 par(mfrow=c(1,2))
 b <- boxplot(d, main="Default Boxplot")  b$stats <- sapply(d, function(x){x<-x[!is.na(x)];s<-sd(x);m<-mean(x);c(min(x),m-s,m,m+s,max(x))})
 b$group <- b$out <- numeric(0) # no outliers when whiskers go to min and max  bxp(b, main="Non-robust Boxplot")

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Gabor Grothendieck
> Sent: Monday, September 26, 2011 7:36 AM
> To: phil at pricom.com.au
> Cc: r-help at stat.math.ethz.ch
> Subject: Re: [R] Boxplot BUT with Mean, SD, Max & Min ?
> 
> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <phil at pricom.com.au> wrote:
> > People,
> >
> > It appears that there is no way of getting Boxplots to plot using 
> > Mean, SD, Max & Min - is there something else that would do what I 
> > want?  I couldn't find it . .
> >
> 
> Try replacing the stats component of boxplot's output with your 
> desired statistics and then feeding that into the lower level bxp 
> function to do the graphics:
> 
> bp <- boxplot(Nile, plot = FALSE)
> bp$stats <- matrix(c(min(Nile), mean(Nile) + c(-1, 0, 1) * sd(Nile), 
> max(Nile)))
> bxp(bp)
> 
> 
> --
> Statistics & Software Consulting
> GKX Group, GKX Associates Inc.
> tel: 1-877-GKX-GROUP
> email: ggrothendieck at gmail.com
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list