Re: [R] Custom Plot - means, SD & 5th-95th% (Plotmeans or Boxplot)

2008-02-17 Thread Gabor Grothendieck
Using builtin dataset stackloss try this:

f <- function(x) replace(quantile(x, c(5, 25, 50, 75, 95)/100), 3, mean(x))
bxp(list(stats = sapply(stackloss, f), n = stackloss, names = names(stackloss)))

and see ?bxp and ?boxplot

On Feb 17, 2008 9:17 PM, Stropharia <[EMAIL PROTECTED]> wrote:
>
> Any help with this problem would be greatly appreciated:
>
> I need to produce a custom plot i haven't come across in R. Basically, I
> want to show means, 1st standard deviation and 5th and 95th percentiles
> visually, using something resembling a boxplot. Is it possible to completely
> customize a boxplot so that it shows means as the bar (instead of, not as
> well as medians), standard deviations at the hinges (instead of IQR) and 5th
> & 95th percentiles at the brackets? The plotmeans function (ggplots) allows
> means to be plotted, but it seems only with confidence intervals, not 5th
> and 95th percentiles, and also without hinges (for standard deviations).
> I've searched the forums and various books and have drawn a blank on this.
> Thanks.
>
> Steve
>
> 
> Steve Worthington
> Ph.D. Candidate
> New York Consortium
> in Evolutionary Primatology
> --
> View this message in context: 
> http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@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@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.


Re: [R] Custom Plot - means, SD & 5th-95th% (Plotmeans or Boxplot)

2008-02-17 Thread David Winsemius
[EMAIL PROTECTED] wrote in
news:[EMAIL PROTECTED]: 

> It's fairly simple to set up something like this for ggplot2:
> 
> install.packages("ggplot2")
> library(ggplot2)
> 
> library(ggplot2)
> 
> q5 <- function(data) {
>  q <- function(p) unname(quantile(data$y, p))
>  data.frame(min = q(0.05), max = q(0.95))
> }
> 
> ggplot(diamonds, aes(x = cut, y = price)) +
> stat_summary(fun="mean_sdl", geom="crossbar", mult=1) +
> stat_summary(fun="q5", geom="linerange")

On WXP with R2.6.1, and version 0.5.7 of ggplot2, ggplott threw an 
error whose second line stated that:
'variable "stat_q5" of mode "function" was not found'

So I defined stat_q5 with the same function code as q5 above and the 
plot appeared.

I have a follow on ggplot2 question for which I have not found the 
correct terms for a successful search: how does one change the 
background fill for the plots? I really would like something other than 
grey backgrounds and they seem to be the default.

-- 
David Winsemius

 
> 
> (see Hmisc::smean.sdl for more details on the first summary
> function). 
> 
> Although from this example you can see that that choice of summary
> statistics probably isn't the best.  You can read more about
> stat_summary (and ggplot2 in general) at
> http://had.co.nz/ggplot2/stat_summary.html.
> 
> Hadley
> 
> On 2/17/08, Stropharia <[EMAIL PROTECTED]> wrote:
>>
>> Any help with this problem would be greatly appreciated:
>>
>> I need to produce a custom plot i haven't come across in R.
>> Basically, I want to show means, 1st standard deviation and 5th and
>> 95th percentiles visually, using something resembling a boxplot. Is
>> it possible to completely customize a boxplot so that it shows
>> means as the bar (instead of, not as well as medians), standard
>> deviations at the hinges (instead of IQR) and 5th & 95th
>> percentiles at the brackets? The plotmeans function (ggplots)
>> allows means to be plotted, but it seems only with confidence
>> intervals, not 5th and 95th percentiles, and also without hinges
>> (for standard deviations). I've searched the forums and various
>> books and have drawn a blank on this. Thanks.
>>
>> Steve
>>
>> 
>> Steve Worthington
>> Ph.D. Candidate
>> New York Consortium
>> in Evolutionary Primatology
>> --
>> View this message in context:
>> http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotm
>> eans-or-Boxplot%29--tp15537706p15537706.html Sent from the R help
>> mailing list archive at Nabble.com. 
>>
>> __
>> R-help@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@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.


Re: [R] Custom Plot - means, SD & 5th-95th% (Plotmeans or Boxplot)

2008-02-17 Thread h . wickham
It's fairly simple to set up something like this for ggplot2:

install.packages("ggplot2")
library(ggplot2)

library(ggplot2)

q5 <- function(data) {
 q <- function(p) unname(quantile(data$y, p))
 data.frame(min = q(0.05), max = q(0.95))
}

ggplot(diamonds, aes(x = cut, y = price)) +
stat_summary(fun="mean_sdl", geom="crossbar", mult=1) +
stat_summary(fun="q5", geom="linerange")

(see Hmisc::smean.sdl for more details on the first summary function).

Although from this example you can see that that choice of summary
statistics probably isn't the best.  You can read more about
stat_summary (and ggplot2 in general) at
http://had.co.nz/ggplot2/stat_summary.html.

Hadley

On 2/17/08, Stropharia <[EMAIL PROTECTED]> wrote:
>
> Any help with this problem would be greatly appreciated:
>
> I need to produce a custom plot i haven't come across in R. Basically, I
> want to show means, 1st standard deviation and 5th and 95th percentiles
> visually, using something resembling a boxplot. Is it possible to completely
> customize a boxplot so that it shows means as the bar (instead of, not as
> well as medians), standard deviations at the hinges (instead of IQR) and 5th
> & 95th percentiles at the brackets? The plotmeans function (ggplots) allows
> means to be plotted, but it seems only with confidence intervals, not 5th
> and 95th percentiles, and also without hinges (for standard deviations).
> I've searched the forums and various books and have drawn a blank on this.
> Thanks.
>
> Steve
>
> 
> Steve Worthington
> Ph.D. Candidate
> New York Consortium
> in Evolutionary Primatology
> --
> View this message in context:
> http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.html
> Sent from the R help mailing list archive at Nabble.com.
>
> __
> R-help@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.
>


-- 
http://had.co.nz/

__
R-help@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] Custom Plot - means, SD & 5th-95th% (Plotmeans or Boxplot)?

2008-02-17 Thread Stropharia

Any help with this problem would be greatly appreciated:

I need to produce a custom plot i haven't come across in R. Basically, I
want to show means, 1st standard deviation and 5th and 95th percentiles
visually, using something resembling a boxplot. Is it possible to completely
customize a boxplot so that it shows means as the bar (instead of, not as
well as medians), standard deviations at the hinges (instead of IQR) and 5th
& 95th percentiles at the brackets? The plotmeans function (ggplots) allows
means to be plotted, but it seems only with confidence intervals, not 5th
and 95th percentiles, and also without hinges (for standard deviations).
I've searched the forums and various books and have drawn a blank on this.
Thanks.

Steve


Steve Worthington
Ph.D. Candidate
New York Consortium
in Evolutionary Primatology
-- 
View this message in context: 
http://www.nabble.com/Custom-Plot---means%2C-SD---5th-95th--%28Plotmeans-or-Boxplot%29--tp15537706p15537706.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@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.