[R] Boxplot 5% and 95% quantile instead of 25% and 75%
Frank E Harrell Jr
f.harrell at vanderbilt.edu
Thu Aug 21 13:17:13 CEST 2008
Joris Meijerink wrote:
> Hi,
>
> I'm new to the whole R-thing as a replacement for Matlab, not disappointed sofar ;)
>
> I found out how to make nice looking boxplots, but i also would like the make a boxplot with 5% and 95% instead of the standard 25 and 75% quantiles.
>
> My csv input looks something like:
> LOCATION FILTER NR DATE VALUE MONTH
> Peelhorst01 1 14-Jan-94 23.07 1
> Peelhorst01 1 28-Jan-94 23.68 1
> Peelhorst01 1 14-Feb-94 23.38 2
> Peelhorst01 1 28-Feb-94 23.27 2
> Peelhorst01 1 14-Mar-94 23.25 3
> Peelhorst01 1 28-Mar-94 23.69 3
> Peelhorst01 1 14-Apr-94 23.63 4
> Peelhorst01 1 28-Apr-94 23.3 4
> Peelhorst01 1 14-May-94 23.14 5
> Peelhorst01 1 28-May-94 23.09 5
> Peelhorst01 1 14-Jun-94 23.06 6
> Peelhorst01 1 28-Jun-94 22.86 6
> Peelhorst01 1 14-Jul-94 22.63 7
> Peelhorst01 1 28-Jul-94 22.48 7
> Peelhorst01 1 14-Aug-94 22.35 8
> Peelhorst01 1 28-Aug-94 22.27 8
> Peelhorst01 1 14-Sep-94 22.21 9
> Peelhorst01 1 28-Sep-94 22.27 9
> Peelhorst01 1 14-Oct-94 22.33 10
> Peelhorst01 1 28-Oct-94 22.28 10
> Peelhorst01 1 14-Nov-94 22.37 11
> Peelhorst01 1 28-Nov-94 22.49 11
> Peelhorst01 1 14-Dec-94 22.56 12
> Peelhorst01 1 28-Dec-94 22.62 12
>
> going on for 13 more years
>
> I used the following to produce a boxplot:
> z <- boxplot(VALUE ~ MONTH, data = reeks,
> plot = FALSE
> )
>
> Then I replace the numbers of the month in jan, feb etc. with
> z$names <- c('jan','feb','mrt','apr','mei','jun','jul','aug','sep','okt','nov','dec')
> and make the boxplot with the bxp function.
>
> Now I was thinking of using the same sollution by replacing row 2 and 4 in z$stats with the results of the quantile function for 5% and 95% but to be able to calculate that I need the vectors of only 1 month without the other months. How can i do that, or is there even a better/easier sollution to my problem?
>
> kind regards
> Joris
>
There is not reason why a box plot need not show multiple quantiles. By
the default the extended box plot obtained by using the lattice
package's bwplot function with the Hmisc package's panel.bpplot function
will provie the 0.05 and 0.95 quantiles and several more, plus the mean.
Type ?panel.bpplot and example(panel.bpplot) for more information.
--
Frank E Harrell Jr Professor and Chair School of Medicine
Department of Biostatistics Vanderbilt University
More information about the R-help
mailing list