0

I have an object,

> str(summary(A$aov[[2]]))
List of 1
 $ :Classes ‘anova’ and 'data.frame':   4 obs. of  5 variables:
  ..$ Df     : num [1:4] 1 1 1 26
  ..$ Sum Sq : num [1:4] 0.00966 0.01137 0.00458 1.13068
  ..$ Mean Sq: num [1:4] 0.00966 0.01137 0.00458 0.04349
  ..$ F value: num [1:4] 0.222 0.261 0.105 NA
  ..$ Pr(>F) : num [1:4] 0.641 0.614 0.748 NA
 - attr(*, "class")= chr [1:2] "summary.aov" "listof"

however I can't seem to figure out how to access "Sum Sq"? I tried the following already,

summary(A$aov[[2]])$'Sum Sq'
summary(A$aov[[2]])[2]
summary(A$aov[[2]])[2,]

Would be even great for learning if I can extract the Sum Sq values without the summary function. For example, typing

> A$aov[[2]]

Terms:
                Adult_Group       Sex Adult_Group:Sex Residuals
Sum of Squares    0.0096577 0.0113658       0.0045836 1.1306777
Deg. of Freedom           1         1               1        26

Residual standard error: 0.2085368
Estimated effects may be unbalanced

> str(A$aov[[2]])
List of 9
 $ coefficients : Named num [1:3] -0.00757 -0.01057 -0.00746
  ..- attr(*, "names")= chr [1:3] "Adult_Group1" "Sex1" "Adult_Group1:Sex1"
 $ residuals    : Named num [1:29] 0.04596 -0.00541 0.41315 -0.24305 -0.06205 ...
  ..- attr(*, "names")= chr [1:29] "2" "3" "4" "5" ...
 $ effects      : Named num [1:29] 0.0983 -0.1066 -0.0677 -0.305 -0.0284 ...
  ..- attr(*, "names")= chr [1:29] "Adult_Group1" "Sex1" "Adult_Group1:Sex1" "" ...
 $ rank         : int 3
 $ fitted.values: Named num [1:29] 4.16e-17 6.51e-17 4.51e-02 3.49e-02 -1.90e-02 ...
  ..- attr(*, "names")= chr [1:29] "2" "3" "4" "5" ...
 $ assign       : int [1:3] 1 2 4
 $ qr           :List of 5
  ..$ qr   : num [1:29, 1:3] -9.30 -5.97e-17 -3.23e-01 -2.50e-01 1.36e-01 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:29] "2" "3" "4" "5" ...
  .. .. ..$ : chr [1:3] "Adult_Group1" "Sex1" "Adult_Group1:Sex1"
  .. ..- attr(*, "assign")= int [1:3] 1 2 4
  ..$ qraux: num [1:3] 1 1 1.28
  ..$ pivot: int [1:3] 1 2 3
  ..$ tol  : num 1e-07
  ..$ rank : int 3
  ..- attr(*, "class")= chr "qr"
 $ df.residual  : int 26
 $ terms        :Classes 'terms', 'formula'  language value ~ Adult_Group + Sex + Region + Adult_Group:Sex + Adult_Group:Region +      Sex:Region + Adult_Group:Sex:Region
  .. ..- attr(*, "variables")= language list(value, Adult_Group, Sex, Region)
  .. ..- attr(*, "factors")= int [1:4, 1:7] 0 1 0 0 0 0 1 0 0 0 ...
  .. .. ..- attr(*, "dimnames")=List of 2
  .. .. .. ..$ : chr [1:4] "value" "Adult_Group" "Sex" "Region"
  .. .. .. ..$ : chr [1:7] "Adult_Group" "Sex" "Region" "Adult_Group:Sex" ...
  .. ..- attr(*, "term.labels")= chr [1:7] "Adult_Group" "Sex" "Region" "Adult_Group:Sex" ...
  .. ..- attr(*, "order")= int [1:7] 1 1 1 2 2 2 3
  .. ..- attr(*, "intercept")= int 1
  .. ..- attr(*, "response")= int 1
  .. ..- attr(*, ".Environment")=<environment: 0x000000005c411db8> 
 - attr(*, "class")= chr [1:2] "aov" "lm"

So I guess from another level, how do I get extract Sum Sq from either,

summary(A$aov[[2]]) or A$aov[[2]]

Would be great to learn how do this since str confuses me.

Konrad Rudolph
  • 530,221
  • 131
  • 937
  • 1,214
Ahdee
  • 4,679
  • 4
  • 34
  • 58
  • 3
    Looks like `summary(A$aov[[2]])[[1]][["Sum Sq"]]` but it would be easier to help and test if you provided a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Providing the `dput()` of the object is more helpful than the `str()`. – MrFlick Feb 15 '17 at 17:00
  • thanks Konrad - funny it makes sense now that you showed me the solution. I also used `summary(A$aov)[[2]][[1]]$"Sum Sq"` and that seem to work as well. – Ahdee Feb 15 '17 at 17:47

0 Answers0