[R] Accessing aov p-value

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 1 10:24:33 CEST 2004


On Wed, 1 Sep 2004, michael watson (IAH-C) wrote:

> I have a data.frame, and want to perform an analysis of variance on each
> row.  

Really?  On one row?  Makes no sense to me!

> I am currently using aov() and summary(), but what I want to do is
> perform an analysis of variance on each row and then append the F
> statistic and the p-value to the end of the row, so I can then use these
> to filter the data later on;  and I want to do all this in a for loop.
> 
> How can I access the F statistic and the p-value from aov()
> programmatically?

They are not there (nor are they printed).  I think you may have meant
from the summary() method for aov, in which case _please_ read the
relevant help page.

Following up example(aov):

summary(npk.aov)[[1]][, 4:5]

is a data frame, with

> print.data.frame(summary(npk.aov)[[1]][, 4:5])
                F value      Pr(>F)
block        4.44666643 0.015938790
N           12.25873421 0.004371812
P            0.54412982 0.474904093
K            6.16568920 0.028795054
N:P          1.37829669 0.263165283
N:K          2.14597201 0.168647879
P:K          0.03119491 0.862752086
Residuals            NA          NA



-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list