[英]Is there a R function that convert p.value to significance code?
summary
displays significance code for p.values. summary
显示 p.values 的显着性代码。 Is there a R function that convert p.value to significance code?是否有将 p.value 转换为显着性代码的 R 函数? for example: 0.02 --> '*'
and 0.005 --> '**'
?例如: 0.02 --> '*'
和 0.005 --> '**'
?
Use symnum
as shown below.使用symnum
如下所示。 ?symnum
for more info. ?symnum
了解更多信息。
p.values <- c(9.5e-15, 0.02)
Signif <- symnum(p.values, corr = FALSE, na = FALSE, cutpoints = c(0,
0.001, 0.01, 0.05, 0.1, 1), symbols = c("***", "**", "*", ".", " "))
giving:给予:
> str(Signif)
Class 'noquote' atomic [1:2] *** *
..- attr(*, "legend")= chr "0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1"
The above code is used in R itself in stats::printCoefmat
(see ?printCoefmat
) which is called from stats:::print.summary.lm
.上面的代码在 R 本身的stats::printCoefmat
(见?printCoefmat
)中使用,它是从stats:::print.summary.lm
。 Note that it produces an object of class "noquote"
and also provides a legend in the "legend"
attribute.请注意,它生成了一个"noquote"
类的对象,并且还在"legend"
属性中提供了一个图例。
Tracking down the code used by summary
, you can find the following in stats:::printCoefmat
:跟踪summary
使用的代码,您可以在stats:::printCoefmat
找到以下stats:::printCoefmat
:
Signif <- symnum(pv, corr = FALSE, na = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
You can create your own function to do it, such as您可以创建自己的函数来执行此操作,例如
signif.num <- function(x) {
symnum(x, corr = FALSE, na = FALSE, legend = FALSE,
cutpoints = c(0, 0.001, 0.01, 0.05, 0.1, 1),
symbols = c("***", "**", "*", ".", " "))
}
signif.num(c(1e-8, 0.01, 0.05, 0.1, 0.2))
(Note the last value is just a space and not visible in the output) (注意最后一个值只是一个空格,在输出中不可见)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.