Skip to content

Problems to extract data from anova table

3 messages · Roberto, Dennis Murphy, David Winsemius

#
Hi,
this is my script
this is results

          Df Sum Sq Mean Sq F value    Pr(>F)    
Ts         2 1232.2  616.11  53.606 3.965e-10 ***
Ts:Te      4 4889.5 1222.37 106.356 4.075e-16 ***
Ts:t       4 6472.1 1618.01 140.780 < 2.2e-16 ***
Ts:Te:t    8 4181.0  522.63  45.473 1.088e-13 ***
Residuals 27  310.3   11.49                      
---
Signif. codes:  0 ?***? 0.001 ?**? 0.01 ?*? 0.05 ?.? 0.1 ? ? 1 

I need to extract "Residuals DF" and "Residuals MeanSq" from results
List of 1
 $ :Classes ?anova? and 'data.frame':   5 obs. of  5 variables:
  ..$ Df     : num [1:5] 2 4 4 8 27
  ..$ Sum Sq : num [1:5] 1232 4889 6472 4181 310
  ..$ Mean Sq: num [1:5] 616.1 1222.4 1618 522.6 11.5
  ..$ F value: num [1:5] 53.6 106.4 140.8 45.5 NA
  ..$ Pr(>F) : num [1:5] 3.96e-10 4.07e-16 1.14e-17 1.09e-13 NA
 - attr(*, "class")= chr [1:2] "summary.aov" "listof"

I try to use results$Df or similar, but nothing seem to work

Thanks in advance

--
View this message in context: http://r.789695.n4.nabble.com/Problems-to-extract-data-from-anova-table-tp3723125p3723125.html
Sent from the R help mailing list archive at Nabble.com.
#
It looks like you want

results[[1]]$Df[5]    # residual df
results[[1]]$`Mean Sq`[5]

Untested without a reproducible example.

Dennis
On Sat, Aug 6, 2011 at 3:00 AM, Roberto <rmoscetti at unitus.it> wrote:
#
On Aug 6, 2011, at 6:00 AM, Roberto wrote:

            
You first need to access the list element, then extract the Df and  
MeanSq vectors.

results[[1]]$Df and results[[1]]$MeanSq would be the vectors

I don't think they are named vectors, at least judging from what I see  
working with the example on the ?aov page (and also looking at str()  
above),  so you need to use your object specific knowledge that they  
are the 5th items of each:

results[[1]]$Df[5] and results[[1]]$MeanSq[5]

If you were doing this programmatically I suppose you could index  
those vectors with

NROW( results[[1]])