有人可以帮我解决这段代码.在循环中,我将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'
Run Code Online (Sandbox Code Playgroud)
fisher.test的返回值是(如果您阅读文档):
值:
Run Code Online (Sandbox Code Playgroud)A list with class ‘"htest"’ containing the following components:
p.value:测试的p值.
conf.int:优势比的置信区间.仅出现在2乘2的情况下,如果参数'conf.int = TRUE'.
R等不知道如何将这样的东西写入文件.更确切地说,它不知道您希望如何将其写入文件.
如果你只想写p值,那么得到p值并写下:
write(f$p.value,file="foo.values",append=TRUE)
Run Code Online (Sandbox Code Playgroud)