Hi:

Try this:

test.summary[[1]][, 5]

It should return a vector of p-values, the last being NA. In your case,
since there is only one non-NA p-value, it is enough to do

test.summary[[1]][, 5][1]

You mean that wasn't obvious?   :)

Explanation:
summary(aovobj) actually returns a list, but that's not obvious from looking
at the print method. If you ask for its names, as in names(summary(aovobj)),
it returns NULL, further adding to the confusion. However, since it is a
list,
summary(aovobj)[[1]]  returns the ANOVA table, and ANOVA tables in R's
modeling functions are typically matrices. The model terms are the rownames
of the matrix (although that isn't obvious at first, either). That being the
case, the p-values are in column 5 (whose column name is 'Pr(>F)' ), so we
can extract that column with
summary(aovobj)[[1]][, 5]       or    summary(aovobj)[[1]][, 'Pr(>F)']
To get the first element of that p-value vector, use
summary(aovobj)[[1]][, 5][1]

HTH,
Dennis

On Wed, Sep 29, 2010 at 3:47 AM, syrvn <ment...@gmx.net> wrote:

>
> Hi,
>
> I did a aov and used summary to obtain the p-value. I tried many ways to
> extract the p-value from
> the summary result but failed. Among others I tried the following:
>
>
>
> > test.summary <-
> > summary(aov(data[,1]~time.points+Error(subject/time.points)))
> > test.summary
>
> Error: subject
>          Df  Sum Sq  Mean Sq F value Pr(>F)
> Residuals  9 0.27467 0.030518
>
> Error: subject:time.points
>            Df   Sum Sq   Mean Sq F value  Pr(>F)
> time.points  2 0.018563 0.0092814  3.1777 0.06578 .
> Residuals   18 0.052574 0.0029208
> ---
> Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
> >
> > as.matrix(test.summary[[1]][,5])
> Error in `[.default`(test.summary[[1]], , 5) :
>  incorrect number of dimensions
> > test.summary$"Error: Within"[[1]]$"Pr(>F)"
> NULL
> > test.summary[[2]][,5]
> Error in `[.default`(test.summary[[2]], , 5) :
>  incorrect number of dimensions
> >
>
>
> Any advise?
> Cheers
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Problems-extracting-p-value-from-summary-aov-tp2718726p2718726.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.
>

        [[alternative HTML version deleted]]

______________________________________________
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.

Reply via email to