如何以预先安装的数据warpbreaks为例隔离摘要中的重要性列(aov())...
> 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
Run Code Online (Sandbox Code Playgroud)
# 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("***", "**", "*", ".", " "))
Run Code Online (Sandbox Code Playgroud)
这将返回一个带有属性的向量:
> sigSymbols
[1] . *** *
attr(,"legend")
[1] 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Run Code Online (Sandbox Code Playgroud)
如果您不想要该legend属性,则可以使用该函数legend = FALSE中的symnum参数.