HEnav
HEnav

Reputation: 133

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). However, I'm only interested in the p-value output. Is there a way to capture just the p-val, and ignore (or not print) everything else? Many thanks!

Upvotes: 2

Views: 4940

Answers (1)

chl
chl

Reputation: 29367

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. So you just need to use $p.value on your R object. Here is an example, in R:

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

Upvotes: 5

Related Questions