title: How to use "if" to overcome data are essentially constant error in r?
body: <p>I need to compare the bacterial gene expression abundance between control and disease samples. I have a large data set which has been read by R. It contains 58,000 rows which are the different genes, and 6 columns. The first three columns represent the values in control whilst the remaining three are from diseased patients.</p>
  
  <p>The data is a matrix and all values are numeric. </p>
  
  <p>I am new to R, and I am trying to figure out how to include an "if" to prevent the error "data are essentially constant", which I am assuming is happening because a lot of the gene expression values are the same in both disease and control group ( some of the gene expression values are 0 in both groups too). </p>
  
  <p>The code I am using is as follows;</p>
  
  <pre class="lang-r prettyprint-override"><code>pvalues &lt;- apply(finalgenecount, 1, function(currRow)
      { t.test(currRow[4:6], currRow[1:3])$p.value } )
  </code></pre>
  
  <p>I basically need to find which genes are most abundant in the disease vs control, and was going to use a foldchange to identify what genes are increased in the disease group based on the pvalues from the above code.</p>
  
  <p>I am struggling to include an "if" correctly to overcome my error.</p>
  
  <p>Please let me know if you have any suggestions. 
  Thank-you </p>
  
  <p>exact error message:</p>
  
  <pre><code>Error in t.test.default(currRow[4:6], currRow[1:3]) : 
    data are essentially constant is the error message.
  </code></pre>