[R] Automatically Extracting F- and P- vals from ANOVA

Uri zvalim at gmail.com
Mon Jan 31 22:06:42 CET 2005


Dear R community,

I'm currently using R to analyze functional Magnetic Resonance Imaging
data.  Each analysis involves running ~120,000 repeated-measures
ANOVAs.

I would like to know if there is any automatic way to access the F-
and P-value data that are associated with each of these 120,000
ANOVAs.

For example, if the summary output (for the 1st ANOVA of 120,000)
shows the following value for factor "C", then I would like to
automatically extract the F value (4.1) and P value (0.13) from the
summary() output:

> summary(anova.1)

Error: S
          Df Sum Sq Mean Sq F value Pr(>F)
Residuals  1   12.5    12.5

Error: S:C
          Df  Sum Sq Mean Sq F value Pr(>F)
C          3 128.500  42.833  4.2131 0.1341
Residuals  3  30.500  10.167

Of course, I would be interested only in factor "C".

I would then push these values to a hash of hashes (i.e, multi-dim
array) that summarizes the results of all the ANOVAs.  {Anova1,
(F=4.21), (P=0.13)} etc'.

I "dumped" a sample aov object, and my impression was that the F and P
values for each effect are not hard coded, but constructed on the fly
by the summary() function.

Is there a script or function that already does what I am looking for?
 If not, my second option would be to sink the summary of each anova
to a text file, and then post-process it, but this latter option is
sub-optimal.

Best,
Uri Hasson




More information about the R-help mailing list