gpt4 book ai didi

file - 将 p 值写入 R 中的文件

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

有人可以帮我处理这段代码吗?在循环中,我将 p 值保存在 f 中,然后我想将 p 值写入文件,但我不知道使用哪个函数写入文件。我的写入功能出错。

{
f = fisher.test(x, y = NULL, hybrid = FALSE, alternative = "greater",
conf.int = TRUE, conf.level = 0.95, simulate.p.value = FALSE)

write(f, file="fisher_pvalues.txt", sep=" ", append=TRUE)
}

Error in cat(list(...), file, sep, fill, labels, append) :
argument 1 (type 'list') cannot be handled by 'cat'

最佳答案

fisher.test 的返回值是(如果您阅读文档):

Value:

 A list with class ‘"htest"’ containing the following components:

p.value: the p-value of the test.

conf.int: a confidence interval for the odds ratio. Only present in the 2 by 2 case and if argument ‘conf.int = TRUE’.



等等等等。R 不知道如何将这样的东西写入文件。更准确地说,它不知道您希望它如何写入文件。

如果您只想写入 p 值,则获取 p 值并写入:
 write(f$p.value,file="foo.values",append=TRUE)

关于file - 将 p 值写入 R 中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8715085/

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