Boxplot BUT with Mean, SD, Max & Min ?

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Boxplot BUT with Mean, SD, Max & Min ?

philip_rhoades
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 . .

Thanks,

Phil.
--
Philip Rhoades

GPO Box 3411
Sydney NSW 2001
Australia
E-mail:  [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Thierry Onkelinx
Dear Phil,

Have a look at the ggplot2 package.

library(ggplot2)
#classic boxplot
ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_boxplot()

#custom boxplot
myboxplot <- cast(cyl ~ ., value = "mpg", data = mtcars, fun = c(min, max, sd, mean))
ggplot(myboxplot, aes(x = factor(cyl))) + geom_boxplot(aes(lower = mean - sd, upper = mean + sd, middle = mean, ymin = min, ymax = max), stat = "identity")

Best regards,

Thierry


> -----Oorspronkelijk bericht-----
> Van: [hidden email] [mailto:[hidden email]]
> Namens Philip Rhoades
> Verzonden: maandag 26 september 2011 15:57
> Aan: [hidden email]
> Onderwerp: [R] Boxplot BUT with Mean, SD, Max & Min ?
>
> 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 . .
>
> Thanks,
>
> Phil.
> --
> Philip Rhoades
>
> GPO Box 3411
> Sydney NSW 2001
> Australia
> E-mail:  [hidden email]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Gabor Grothendieck
In reply to this post by philip_rhoades
On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]> 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

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

William Dunlap
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: [hidden email] [mailto:[hidden email]] On Behalf Of Gabor
> Grothendieck
> Sent: Monday, September 26, 2011 7:36 AM
> To: [hidden email]
> Cc: [hidden email]
> Subject: Re: [R] Boxplot BUT with Mean, SD, Max & Min ?
>
> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

philip_rhoades
In reply to this post by Gabor Grothendieck
Gabor,


On 2011-09-27 00:35, Gabor Grothendieck wrote:

> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]>
> 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)


Thanks for that!  What is the syntax when there is more than one set of
data (ie a two dimensional vector)?  I tried messing around with stuff
like:

   mean(Nile[,2] etc

but I get subscript out of range errors  . .

Thanks,

Phil.
--
Philip Rhoades

GPO Box 3411
Sydney NSW 2001
Australia
E-mail:  [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Vining, Kelly
In reply to this post by William Dunlap
You can also eliminate the outliers from boxplots with the "outline=F" parameter.

--Kelly V.

-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of William Dunlap
Sent: Monday, September 26, 2011 8:12 AM
To: [hidden email]
Cc: [hidden email]
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: [hidden email]
> [mailto:[hidden email]] On Behalf Of Gabor Grothendieck
> Sent: Monday, September 26, 2011 7:36 AM
> To: [hidden email]
> Cc: [hidden email]
> Subject: Re: [R] Boxplot BUT with Mean, SD, Max & Min ?
>
> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]> 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
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Gabor Grothendieck
In reply to this post by philip_rhoades
On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]> wrote:

> Gabor,
>
>
> On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>
>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]>
>> 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)
>
>
> Thanks for that!  What is the syntax when there is more than one set of data
> (ie a two dimensional vector)?  I tried messing around with stuff like:
>
>  mean(Nile[,2] etc
>
> but I get subscript out of range errors  . .
>

Bill's example shows  how to do it with a list of numeric vectors.
Here is another example using the built in anscombe and making use of
my prior code, Bill's and Vining's:

bp <- boxplot(anscombe, plot = FALSE)
bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1, 0,
1) * sd(x), max(x)))
bxp(bp, outline = FALSE)

--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

philip_rhoades
Gabor, Bill,


On 2011-09-27 02:51, Gabor Grothendieck wrote:

> On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]>
> wrote:
>> Gabor,
>>
>>
>> On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>>
>>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades
>>> <[hidden email]>
>>> 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)
>>
>>
>> Thanks for that!  What is the syntax when there is more than one set
>> of data
>> (ie a two dimensional vector)?  I tried messing around with stuff
>> like:
>>
>>  mean(Nile[,2] etc
>>
>> but I get subscript out of range errors  . .
>>
>
> Bill's example shows  how to do it with a list of numeric vectors.
> Here is another example using the built in anscombe and making use of
> my prior code, Bill's and Vining's:
>
> bp <- boxplot(anscombe, plot = FALSE)
> bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1, 0,
> 1) * sd(x), max(x)))
> bxp(bp, outline = FALSE)


Interesting! - I've learnt something about anscombe and sapply and
other stuff (thanks again!) but I think I mis-spoke before.  I think
what I want is a list of numeric vectors but when I created tarr:

   tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )

I couldn't get it to work with the original code . . now I have had a
closer look at Bill's code . .

On the original question though, why isn't there something "off the
shelf" that will do what I want?  Surely, a "boxplot" using mean, SD,
max and min would be a common enough need to justify it?

Thanks,

Phil.

--
Philip Rhoades

GPO Box 3411
Sydney NSW 2001
Australia
E-mail:  [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

William Revelle
Dear Phil,
    An alternative solution is to draw a regular Tukey Box Plot but
overlay the means +/- 1 sd:

boxplot(anscombe)
psych:::error.bars(anscombe,sd=TRUE,add=TRUE)

Bill


At 3:45 AM +1000 9/27/11, Philip Rhoades wrote:

>Gabor, Bill,
>
>
>On 2011-09-27 02:51, Gabor Grothendieck wrote:
>>On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]> wrote:
>>>Gabor,
>>>
>>>
>>>On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>>>
>>>>On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]>
>>>>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)
>>>
>>>
>>>Thanks for that!  What is the syntax when there is more than one set of data
>>>(ie a two dimensional vector)?  I tried messing around with stuff like:
>>>
>>>  mean(Nile[,2] etc
>>>
>>>but I get subscript out of range errors  . .
>>>
>>
>>Bill's example shows  how to do it with a list of numeric vectors.
>>Here is another example using the built in anscombe and making use of
>>my prior code, Bill's and Vining's:
>>
>>bp <- boxplot(anscombe, plot = FALSE)
>>bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1, 0,
>>1) * sd(x), max(x)))
>>bxp(bp, outline = FALSE)
>
>
>Interesting! - I've learnt something about anscombe and sapply and
>other stuff (thanks again!) but I think I mis-spoke before.  I think
>what I want is a list of numeric vectors but when I created tarr:
>
>   tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )
>
>I couldn't get it to work with the original code . . now I have had
>a closer look at Bill's code . .
>
>On the original question though, why isn't there something "off the
>shelf" that will do what I want?  Surely, a "boxplot" using mean,
>SD, max and min would be a common enough need to justify it?
>
>Thanks,
>
>Phil.
>
>--
>Philip Rhoades
>
>GPO Box 3411
>Sydney NSW 2001
>Australia
>E-mail:  [hidden email]
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Gabor Grothendieck
In reply to this post by philip_rhoades
On Mon, Sep 26, 2011 at 1:45 PM, Philip Rhoades <[hidden email]> wrote:

> Gabor, Bill,
>
>
> On 2011-09-27 02:51, Gabor Grothendieck wrote:
>>
>> On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]>
>> wrote:
>>>
>>> Gabor,
>>>
>>>
>>> On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>>>
>>>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]>
>>>> 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)
>>>
>>>
>>> Thanks for that!  What is the syntax when there is more than one set of
>>> data
>>> (ie a two dimensional vector)?  I tried messing around with stuff like:
>>>
>>>  mean(Nile[,2] etc
>>>
>>> but I get subscript out of range errors  . .
>>>
>>
>> Bill's example shows  how to do it with a list of numeric vectors.
>> Here is another example using the built in anscombe and making use of
>> my prior code, Bill's and Vining's:
>>
>> bp <- boxplot(anscombe, plot = FALSE)
>> bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1, 0,
>> 1) * sd(x), max(x)))
>> bxp(bp, outline = FALSE)
>
>
> Interesting! - I've learnt something about anscombe and sapply and other
> stuff (thanks again!) but I think I mis-spoke before.  I think what I want
> is a list of numeric vectors but when I created tarr:
>
>  tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )
>
> I couldn't get it to work with the original code . . now I have had a closer
> look at Bill's code . .
>
> On the original question though, why isn't there something "off the shelf"
> that will do what I want?  Surely, a "boxplot" using mean, SD, max and min
> would be a common enough need to justify it?
>

tarr is not a list or a data frame. Use.data.frame(tarr) so that  it
uses the same assumptions as the examples in this thread.

I believe there is no such facility due to a philosophical opposition.
 Unless someone were careful they would naturally assume that boxplots
were shown even though that is not the case here.


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

philip_rhoades
Gabor,


On 2011-09-27 04:31, Gabor Grothendieck wrote:

> On Mon, Sep 26, 2011 at 1:45 PM, Philip Rhoades <[hidden email]>
> wrote:
>> Gabor, Bill,
>>
>>
>> On 2011-09-27 02:51, Gabor Grothendieck wrote:
>>>
>>> On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades
>>> <[hidden email]>
>>> wrote:
>>>>
>>>> Gabor,
>>>>
>>>>
>>>> On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>>>>
>>>>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades
>>>>> <[hidden email]>
>>>>> 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)
>>>>
>>>>
>>>> Thanks for that!  What is the syntax when there is more than one
>>>> set of
>>>> data
>>>> (ie a two dimensional vector)?  I tried messing around with stuff
>>>> like:
>>>>
>>>>  mean(Nile[,2] etc
>>>>
>>>> but I get subscript out of range errors  . .
>>>>
>>>
>>> Bill's example shows  how to do it with a list of numeric vectors.
>>> Here is another example using the built in anscombe and making use
>>> of
>>> my prior code, Bill's and Vining's:
>>>
>>> bp <- boxplot(anscombe, plot = FALSE)
>>> bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1,
>>> 0,
>>> 1) * sd(x), max(x)))
>>> bxp(bp, outline = FALSE)
>>
>>
>> Interesting! - I've learnt something about anscombe and sapply and
>> other
>> stuff (thanks again!) but I think I mis-spoke before.  I think what
>> I want
>> is a list of numeric vectors but when I created tarr:
>>
>>  tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )
>>
>> I couldn't get it to work with the original code . . now I have had
>> a closer
>> look at Bill's code . .
>>
>> On the original question though, why isn't there something "off the
>> shelf"
>> that will do what I want?  Surely, a "boxplot" using mean, SD, max
>> and min
>> would be a common enough need to justify it?
>>
>
> tarr is not a list or a data frame. Use.data.frame(tarr) so that  it
> uses the same assumptions as the examples in this thread.


Thanks!


> I believe there is no such facility due to a philosophical
> opposition.


A software design thing or a stats thing?


>  Unless someone were careful they would naturally assume that
> boxplots
> were shown even though that is not the case here.


I don't understand what you mean here . .

Regards,

Phil.
--
Philip Rhoades

GPO Box 3411
Sydney NSW 2001
Australia
E-mail:  [hidden email]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

Gabor Grothendieck
On Mon, Sep 26, 2011 at 3:24 PM, Philip Rhoades <[hidden email]> wrote:

> Gabor,
>
>
> On 2011-09-27 04:31, Gabor Grothendieck wrote:
>>
>> On Mon, Sep 26, 2011 at 1:45 PM, Philip Rhoades <[hidden email]>
>> wrote:
>>>
>>> Gabor, Bill,
>>>
>>>
>>> On 2011-09-27 02:51, Gabor Grothendieck wrote:
>>>>
>>>> On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]>
>>>> wrote:
>>>>>
>>>>> Gabor,
>>>>>
>>>>>
>>>>> On 2011-09-27 00:35, Gabor Grothendieck wrote:
>>>>>>
>>>>>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades <[hidden email]>
>>>>>> 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)
>>>>>
>>>>>
>>>>> Thanks for that!  What is the syntax when there is more than one set of
>>>>> data
>>>>> (ie a two dimensional vector)?  I tried messing around with stuff like:
>>>>>
>>>>>  mean(Nile[,2] etc
>>>>>
>>>>> but I get subscript out of range errors  . .
>>>>>
>>>>
>>>> Bill's example shows  how to do it with a list of numeric vectors.
>>>> Here is another example using the built in anscombe and making use of
>>>> my prior code, Bill's and Vining's:
>>>>
>>>> bp <- boxplot(anscombe, plot = FALSE)
>>>> bp$stats <- sapply(anscombe, function(x) c(min(x), mean(x) + c(-1, 0,
>>>> 1) * sd(x), max(x)))
>>>> bxp(bp, outline = FALSE)
>>>
>>>
>>> Interesting! - I've learnt something about anscombe and sapply and other
>>> stuff (thanks again!) but I think I mis-spoke before.  I think what I
>>> want
>>> is a list of numeric vectors but when I created tarr:
>>>
>>>  tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )
>>>
>>> I couldn't get it to work with the original code . . now I have had a
>>> closer
>>> look at Bill's code . .
>>>
>>> On the original question though, why isn't there something "off the
>>> shelf"
>>> that will do what I want?  Surely, a "boxplot" using mean, SD, max and
>>> min
>>> would be a common enough need to justify it?
>>>
>>
>> tarr is not a list or a data frame. Use.data.frame(tarr) so that  it
>> uses the same assumptions as the examples in this thread.
>
>
> Thanks!
>
>
>> I believe there is no such facility due to a philosophical opposition.
>
>
> A software design thing or a stats thing?
>
>
>>  Unless someone were careful they would naturally assume that boxplots
>> were shown even though that is not the case here.
>
>
> I don't understand what you mean here . .
>

Boxplots are really standard.  When one sees what appears to be a
boxplot they tend to assume it is a boxplot as defined everywhere else
and not some non-standard graphical representation where each of the
statistics graphed means something different than expected.



--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Boxplot BUT with Mean, SD, Max & Min ?

PIKAL Petr
In reply to this post by philip_rhoades
>
> Gabor, Bill,
>
>
> On 2011-09-27 02:51, Gabor Grothendieck wrote:
> > On Mon, Sep 26, 2011 at 12:11 PM, Philip Rhoades <[hidden email]>
> > wrote:
> >> Gabor,
> >>
> >>
> >> On 2011-09-27 00:35, Gabor Grothendieck wrote:
> >>>
> >>> On Mon, Sep 26, 2011 at 9:56 AM, Philip Rhoades
> >>> <[hidden email]>
> >>> 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 . .

<snip>

>
>
> Interesting! - I've learnt something about anscombe and sapply and
> other stuff (thanks again!) but I think I mis-spoke before.  I think
> what I want is a list of numeric vectors but when I created tarr:
>
>    tarr <- array( dim = c( 5,3 ), c( 1,2,3,4,5,2,3,4,5,6,3,4,5,6,7 ) )
>
> I couldn't get it to work with the original code . . now I have had a
> closer look at Bill's code . .
>
> On the original question though, why isn't there something "off the
> shelf" that will do what I want?  Surely, a "boxplot" using mean, SD,
> max and min would be a common enough need to justify it?

It is questionable. I use boxplots to demonstrate that underlaying data
are more or less symmetrical or deviate from symetrical (normal)
distribution. Boxplot with mean, sd are, in this respect, rather unusable.


I would call such plots differently let say "meanplot" or "centralplot" to
avoid confusion with real boxplot.

My 0.02 Kc

Regards
Petr

>
> Thanks,
>
> Phil.
>
> --
> Philip Rhoades
>
> GPO Box 3411
> Sydney NSW   2001
> Australia
> E-mail:  [hidden email]
>
> ______________________________________________
> [hidden email] 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.

______________________________________________
[hidden email] 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.