title: Error: all entries of 'x' must be nonnegative and finite in fisher.test
body: <p>I am running a Fisher Exact test on some contingency matrix in R. However, using this code:</p>
  
  <pre><code>for (class in 1:5) {
      for (test in c("amp", "del")) {
          prefisher &lt;- read.table("prefisher.txt", sep="\t", row.names=1)
          for (gene in rownames(prefisher)) {
              genemat &lt;- matrix(prefisher[gene,], ncol=2)
              print(genemat)
              result &lt;- fisher.test(genemat)
              write(paste(gene, result$estimate, result$p.value, sep = "\t"), "")
          }
      }
  }
  </code></pre>
  
  <p>I am getting the following error:</p>
  
  <pre><code>    [,1] [,2]
  [1,] 1    0   
  [2,] 101  287 
  Error in fisher.test(genemat): all entries of 'x' must be nonnegative and finite
  </code></pre>
  
  <p>As you can see, the matrix <code>genemat</code> is nonnegative and finite. </p>
  
  <p><code>str(genemat)</code> returns:</p>
  
  <pre><code>List of 4
   $ : int 1
   $ : int 101
   $ : int 0
   $ : int 287
    - attr(*, "dim")= int [1:2] 2 2
  </code></pre>
  
  <p>What am I doing wrong?</p>
  
  <p>Thanks</p>