[R] Extract p value from aov

Jim Lemon jim at bitwrit.com.au
Tue Oct 10 03:25:27 CEST 2006


Hi all,

In assessing the concordance of two sets of ANOVA results, I would like
to extract the p values from the summaries. I had a look at previous
answers to this problem, and the suggestions do not seem to work:

# toy example
test.df<-data.frame(subno=c(1:50,1:50),
  ndrinks=c(rpois(50,4.5),rpois(50,4)),
  b4after=c(rep(1,50),rep(-1,50)))
test.summary<-summary(aov(ndrinks~b4after+Error(subno),test.df))
test.summary[[2]][,5]
Error in test.summary[[2]][, 5] : incorrect number of dimensions

and so on.

I can get the structure of the object:

str(test.summary[[2]])
List of 1
  $ :Classes anova  and `data.frame':    2 obs. of  5 variables:
   ..$ Df     : num [1:2] 1 269
   ..$ Sum Sq : num [1:2]   60.2 1792.0
   ..$ Mean Sq: num [1:2] 60.24  6.66
   ..$ F value: num [1:2] 9.04   NA
   ..$ Pr(>F) : num [1:2] 0.00289      NA
  - attr(*, "class")= chr [1:2] "summary.aov" "listof"

but if I try to extract it:

test.summary[[2]]$'Pr(>F)'
NULL

I assume that the incantation has changed.

Using R-2.3.1 - Tried this on both Windows XP and FC4 Linux

Jim



More information about the R-help mailing list