如何在扫帚包的tidy()函数输出中添加星号? [英] How can I add stars to broom package's tidy() function output?
本文介绍了如何在扫帚包的tidy()函数输出中添加星号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在R中使用扫帚包的 tidy()
函数来打印我的模型摘要.
I have been using the broom package's tidy()
function in R to print my model summaries.
但是, tidy()
函数返回不带星星的p值,这使许多习惯于在模型摘要中看到星星的人感到有些奇怪.
However, the tidy()
function returns p-values without stars, which makes it a bit weird for many people who are used to seeing stars in model summaries.
有人知道一种在输出中添加星星的方法吗?
Does anyone know a way to add stars to the output?
推荐答案
我们可以使用来自 gtools
的便捷函数 stars.pval
来实现
We can use a convenient function stars.pval
from gtools
to do this
library(gtools)
library(broom)
library(dplyr)
data(mtcars)
mtcars %>%
lm(mpg ~ wt + qsec, .) %>%
tidy %>%
mutate(signif = stars.pval(p.value))
# term estimate std.error statistic p.value signif
#1 (Intercept) 19.746223 5.2520617 3.759709 7.650466e-04 ***
#2 wt -5.047982 0.4839974 -10.429771 2.518948e-11 ***
#3 qsec 0.929198 0.2650173 3.506179 1.499883e-03 **
这篇关于如何在扫帚包的tidy()函数输出中添加星号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文