I have a simple question. How to convert a data frame into a contingency table for Fisher's Exact Test?
I have data
having about 19000 rows:
head(data)
R_T1 R_T2 NR_T1 NR_T2
GMNN 14 60 70 157
GORASP2 7 67 39 188
TTC34 5 69 41 186
ZXDC 8 66 37 190
ASAH2 9 65 46 181
I would like to transform each row into a contingency table to perform Fisher's Exact Test. For example, for GMNN
:
R NR
T1 14 70
T2 60 157
fisher.test(GMNN, alternative="two.sided")
Fisher's Exact Test for Count Data
data: GMNN
p-value = 0.05273
alternative hypothesis: true odds ratio is not equal to 1
95 percent confidence interval:
0.2531445 1.0280271
sample estimates:
odds ratio
0.5243787
Since I have 19000 rows of data, I would prefer to output to be:
R_T1 R_T2 NR_T1 NR_T2 p-value odds_ratio
GMNN 14 60 70 157 0.05273 0.5243787
GORASP2 7 67 39 188 0.1367 0.504643
TTC34 5 69 41 186 0.02422 0.3297116
ZXDC 8 66 37 190 0.3474 0.6233377
ASAH2 9 65 46 181 0.1648 0.5458072
I am lost on how to do this. Could someone help? Thanks!