title: How to loop chi sq test in R
body: <p>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.</p>
  
  <pre><code>   altCount refCount
       8        6
       3        7
       4        9 
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>bcz &lt;- 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, 
   )
  </code></pre>
  
  <p>but I do not know how to loop it for whole table. Could you please explain me how to do it with all details?</p>
  
  <p><a href="http://i.stack.imgur.com/tMRGR.png" rel="nofollow">enter image description here</a></p>