Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isolate the significance column from summary(aov()) in r

Tags:

r

summary

How do I isolate the significance column in summary(aov()) taking the pre-installed data warpbreaks as an example...

> a<-summary(aov(breaks~wool*tension,data=warpbreaks))
> a
             Df Sum Sq Mean Sq F value   Pr(>F)    
wool          1    451   450.7   3.765 0.058213 .  
tension       2   2034  1017.1   8.498 0.000693 ***
wool:tension  2   1003   501.4   4.189 0.021044 *  
Residuals    48   5745   119.7                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

> somefunction(a)[,6]

1     .  
2     ***
3     *
4     
like image 436
Brian Avatar asked Mar 20 '13 09:03

Brian


1 Answers

# Extract the p-values
pvals <- a[[1]][["Pr(>F)"]]

# Use the symnum function to produce the symbols
sigSymbols <- symnum(pvals, na = FALSE, 
                     cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1), 
                     symbols = c("***", "**", "*", ".", " "))

This returns a vector with an attribute:

> sigSymbols
[1] .   *** *      
attr(,"legend")
[1] 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

If you don't want the legend attribute, you can use the argument legend = FALSE in the symnum function.

like image 131
Sven Hohenstein Avatar answered Nov 15 '22 09:11

Sven Hohenstein