title: NA's appearing when subtracting one number from another in R
body: <p>I have data in the following format in R:</p>
  
  <pre><code>Col1 Col2 
  1    1
  2    1
  4    0
  0    0
  2    2
  .    .
  .    .
  .    .
  </code></pre>
  
  <p>I'm using the following script to work out the percentage differences between Col1 &amp; Col2 in each row.  </p>
  
  <pre><code>temp &lt;- matrix(numeric(),dim(data)[1],1)
  
  for (i in 1:dim(data)[1])
  {
   temp[i,1]&lt;- ((data[i,1]-data[i,2)/data[i,1])*100
  }
  </code></pre>
  
  <p>For some reason my output file (temp) has some NA's in it. They are occurring even when 0-0. Does anyone know why it isn't just producing a 0 as opposed to NA? Some sums of 0-0 are producing a 0 as opposed to NA so I can't see any real pattern. </p>
  
  <p>Any help would be much appreciated. Thanks, </p>