[R] retrieving stats from bwplot

deepayan.sarkar at gmail.com deepayan.sarkar at gmail.com
Wed Jul 4 09:04:58 CEST 2007


On 7/3/07, Héctor Villalobos <hvillalo at ipn.mx> wrote:
> Hi all,
>
> I want to retrieve the stats from a 'bwplot' with one factor. I have read
> the help for 'panel'
> function and I'm aware of the option 'stats' which defaults to
> 'boxplot.stats' but I didn't
> understand it well and therefore I am unable to get what I need.

I'm not sure what bwplot has to do with this. Perhaps this will help:

> foo <- with(OrchardSprays, split(decrease, treatment))
> str(foo)
List of 8
 $ A: num [1:8] 2 2 5 4 5 12 4 3
 $ B: num [1:8] 8 6 4 10 7 4 8 14
 $ C: num [1:8] 15 84 16 9 17 29 13 19
 $ D: num [1:8] 57 36 22 51 28 27 20 39
 $ E: num [1:8] 95 51 39 114 43 47 61 55
 $ F: num [1:8] 90 69 87 20 71 44 57 114
 $ G: num [1:8] 92 71 72 24 60 77 72 80
 $ H: num [1:8] 69 127 72 130 81 76 81 86
> boxplot.stats(foo$A)
$stats
[1] 2.0 2.5 4.0 5.0 5.0

$n
[1] 8

$conf
[1] 2.603464 5.396536

$out
[1] 12

> bxp.stats <- lapply(foo, boxplot.stats)
> str(bxp.stats)
List of 8
 $ A:List of 4
  ..$ stats: num [1:5] 2 2.5 4 5 5
  ..$ n    : int 8
  ..$ conf : num [1:2] 2.60 5.40
  ..$ out  : num 12
 $ B:List of 4
  ..$ stats: num [1:5] 4 5 7.5 9 14
  ..$ n    : int 8
  ..$ conf : num [1:2] 5.27 9.73
  ..$ out  : num(0)
 $ C:List of 4
  ..$ stats: num [1:5] 9 14 16.5 24 29
  ..$ n    : int 8
  ..$ conf : num [1:2] 10.9 22.1
  ..$ out  : num 84
 $ D:List of 4
  ..$ stats: num [1:5] 20 24.5 32 45 57
  ..$ n    : int 8
  ..$ conf : num [1:2] 20.5 43.5
  ..$ out  : num(0)
 $ E:List of 4
  ..$ stats: num [1:5] 39 45 53 78 114
  ..$ n    : int 8
  ..$ conf : num [1:2] 34.6 71.4
  ..$ out  : num(0)
 $ F:List of 4
  ..$ stats: num [1:5] 20 50.5 70 88.5 114
  ..$ n    : int 8
  ..$ conf : num [1:2] 48.8 91.2
  ..$ out  : num(0)
 $ G:List of 4
  ..$ stats: num [1:5] 60 65.5 72 78.5 92
  ..$ n    : int 8
  ..$ conf : num [1:2] 64.7 79.3
  ..$ out  : num 24
 $ H:List of 4
  ..$ stats: num [1:5]  69  74  81 106 130
  ..$ n    : int 8
  ..$ conf : num [1:2] 62.8 99.2
  ..$ out  : num(0)


If you want combinations defined by more than one factor, you could
use something like

with(OrchardSprays, split(decrease, interaction(treatment, colpos)))

(although this is a bad example, since there is only one observation
per combination)

-Deepayan



More information about the R-help mailing list