I have the table with alternative and reference allele counts. How could I loop chi sq test in R to run it for each row? I attached the picture of my table. I need to perform chi sq test with altCount and refCount columns.
altCount refCount
8 6
3 7
4 9
I need the p-value for each row. I am very new to R. I figured out how to perform chi sq test on individual rows but since I have several thousands rows I need to make a loop to run it all at once. I did:
bcz <- read.delim("C:/cygwin64/home/sbomb/tables/bc_z_alleles.csv")
a = bcz[1,6]
b = bcz[1,7]
c = c(a,b)
d = c(0.5,0.5)
chisq.test(
x = c,
p = d,
)
but I do not know how to loop it for whole table. Could you please explain me how to do it with all details?