[R] Problems extracting p-value from summary(aov(...))

peter dalgaard pdalgd at gmail.com
Wed Sep 29 14:56:14 CEST 2010


On Sep 29, 2010, at 14:25 , Dennis Murphy wrote:

> 
> test.summary[[1]][, 5][1]
> 
> You mean that wasn't obvious?   :)

Worse, it doesn't actually work...

> test.summary <- summary(npk.aovE)
> test.summary[[1]][, 5]
Error in `[.default`(test.summary[[1]], , 5) : 
  incorrect number of dimensions
> test.summary$"Error: block"[[1]][, 5]
[1] 0.5252361        NA
> test.summary[[1]][[1]][, 5]
[1] 0.5252361        NA

I.e., you need an extra list extraction operator. The data structure goes

List of 2
 $ Error: block :List of 1
  ..$ :Classes ‘anova’ and 'data.frame':	2 obs. of  5 variables:
  .. ..$ Df     : num [1:2] 1 4
  .. ..$ Sum Sq : num [1:2] 37 306
...
 and the intermediate list has class ("summary.aov","listof"). I believe the point is that you can have a matrix LHS and get a table for each of its columns.

-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list