title: Iterate 2x2 tables and fishers exact over multiple columns in large dataframe in R
body: <p>I'm new to <a href="/questions/tagged/r" class="post-tag" title="show questions tagged &#39;r&#39;" rel="tag">r</a> and I'm looking for help with looping and iterating over a large data frame to create multiple 2x2 tables with the <code>table()</code> function, followed by <code>fishers.test()</code> on each table to export the odds ratio and <a href="/questions/tagged/p-value" class="post-tag" title="show questions tagged &#39;p-value&#39;" rel="tag">p-value</a>s. 
  My <a href="/questions/tagged/dataframe" class="post-tag" title="show questions tagged &#39;dataframe&#39;" rel="tag">dataframe</a>s have cluster(s) and genes as columns like this: </p>
  
  <pre><code>**df**
  Tag  Cluster  Gene1  Gene2  Gene3  Gene4
  1    a        1      0      0      1
  2    b        0      1      1      1
  3    c        1      1      0      0  
  4    d        0      0      0      1
  5    e        1      1      0      0
  </code></pre>
  
  <p>The is the code I want iterated and looped. </p>
  
  <pre><code>tab&lt;-table(df$Cluster =="a", df$Gene1)
  fisher.test(tab)
  </code></pre>
  
  <p>I'm not sure where to begin and would appreciate any help.</p>
  
  <p>Thanks!</p>
  
  <p>P.S my actually data frame dimensions are 1010 x 191</p>