简体   繁体   English

R fisher.test仅打印p值

[英]R fisher.test print only p-value

I'm trying to use the fisher.test function, which is called from a perl script (using R::bridge). 我正在尝试使用fisher.test函数,该函数从perl脚本调用(使用R :: bridge)。 However, I'm only interested in the p-value output. 但是,我只对p值输出感兴趣。 Is there a way to capture just the p-val, and ignore (or not print) everything else? 有没有办法只捕获p值,而忽略(或不打印)其他所有内容? Many thanks! 非常感谢!

If you take a look at the values returned by a call to the fisher.test() function (see help(fisher.test) in R), you will notice that there is p.value among others. 如果你看看通过向一个调用返回的值fisher.test()函数(见help(fisher.test)在R),你会发现,有p.value等等。 So you just need to use $p.value on your R object. 因此,您只需要在R对象上使用$p.value Here is an example, in R: 这是R中的示例:

tab <- replicate(2, sample(LETTERS[1:3], 10, rep=TRUE))
fisher.test(table(tab[,1], tab[,2]))$p.value

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM