gpt4 book ai didi

r - 是否有舍入 p 值的函数?

转载 作者:行者123 更新时间:2023-12-04 04:17:10 24 4
gpt4 key购买 nike

glm , lm和其他功能在 产生的pvalues,有善意的打印。例如 :

p found   | p printed
--------- | -----
0.000032 | <0.001 ***
0.012322 | 0.012 **
0.233432 | 0.233

必须有一个内置函数来产生这个,但我没有找到它。我在 R 文档、Google 和 SO 中搜索但没有成功。目前我使用一个手工制作的函数,但我必须复制粘贴它并在每次执行分析时调用它,我想为输出表生成漂亮的 pvalue。

最佳答案

(感谢@James 的评论,我回答了我自己的问题。)

使用 format.pval有正确的论据。 digitseps是最重要的。

例子 :

pvalues <- c(0.99, 0.2, 0.32312, 0.0000123213, 0.002)

format.pval(pv = pvalues,

# digits : number of digits, but after the 0.0
digits = 2,

# eps = the threshold value above wich the
# function will replace the pvalue by "<0.0xxx"
eps = 0.001,

# nsmall = how much tails 0 to keep if digits of
# original value < to digits defined
nsmall = 3
)

# "0.990" "0.200" "0.323" "<0.001" "0.002"
format.pval返回一个字符向量。

要获得星星只需使用 ifelse或者写一个函数
ifelse(pvalues < 0.05, "*", "")

关于r - 是否有舍入 p 值的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24677631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com