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

John Fox jfox at mcmaster.ca
Mon Jan 31 23:26:52 CET 2005


Dear Uri,

You can save the object produced by summary() (i.e., assign it to a
variable, not print it and dump it to a file) and extract what you want from
that. You can use str() to see the structure of the object.

I hope this helps,
 John

--------------------------------
John Fox
Department of Sociology
McMaster University
Hamilton, Ontario
Canada L8S 4M4
905-525-9140x23604
http://socserv.mcmaster.ca/jfox 
-------------------------------- 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Uri
> Sent: Monday, January 31, 2005 4:07 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Automatically Extracting F- and P- vals from ANOVA
> 
> 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
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html




More information about the R-help mailing list