[R] how to read the "Sum Sq" - column from summary.aov()

Bertolt Meyer bmeyer at sozpsy.uzh.ch
Thu Feb 3 14:27:23 CET 2011


Dear Peter,

thank you so much for the quick and helpful reply - it was exactly what I was looking for.

Regards,
Bertolt

Am 03.02.2011 um 13:49 schrieb Peter Ehlers:

> On 2011-02-03 04:30, Bertolt Meyer wrote:
>> Dear R-Users,
>> 
>> I have a trivial problem, but extensive googling and ??'ing did not solve it: I want to obtain the sums of squares from a summary.aov() object for later use. Example:
>> 
>>> DV<- rnorm(100)
>>> IV1<- as.factor(rep(c("male", "female"), times = 50))
>>> IV2<- as.factor(rep(c("young", "old"), times = 50))
>>> 
>>> summary(aov(DV ~ IV1 * IV2))
>> 
>>             Df Sum Sq Mean Sq F value Pr(>F)
>> IV1          1  0.215 0.21499  0.2277 0.6343
>> Residuals   98 92.523 0.94411
>> 
>> How can I store the sums of squares in a variable for later use? Like this:
>> 
>>> some.magic.command()
>> [1]  0.215  92.523
> 
> str() is your friend.
> 
> str( summary(aov(DV ~ IV1 * IV2)) )
> 
> shows that the summary is a list containing a data.frame.
> Use
> 
> summary(aov(DV ~ IV1 * IV2))[[1]]
> 
> to extract the data.frame and any one of
> 
> summary(aov(DV ~ IV1 * IV2))[[1]][, 2]
> summary(aov(DV ~ IV1 * IV2))[[1]][, 'Sum Sq']
> summary(aov(DV ~ IV1 * IV2))[[1]]$'Sum Sq'
> 
> to extract the sum-of-squares vector.
> 
> Peter Ehlers
> 
>> 
>> Thank you,
>> Bertolt



More information about the R-help mailing list