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
# 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With