title: Subtract multiple columns ignoring NA
body: <p>I'm fairly new to R and have run into an issue with NA's. This question may have been answered elsewhere but I can't seem to find the answer. I'm trying to do sort of the opposite of <code>rowSums()</code> in that I'm trying to subtract <code>x2</code> and <code>x3</code> from <code>x1</code> in order to generate <code>x4</code> without NA's. The code I'm currently using is as follows:</p>
  
  <pre><code>&gt; x &lt;- data.frame(x1 = 3, x2 = c(4:1, 2:5), x3=c(1,NA))
  &gt; x$x4=x$x1-x$x2-x$x3
  &gt; x
  
    x1 x2 x3 x4
  1  3  4  1 -2
  2  3  3 NA NA
  3  3  2  1  0
  4  3  1 NA NA
  5  3  2  1  0
  6  3  3 NA NA
  7  3  4  1 -2
  8  3  5 NA NA
  </code></pre>
  
  <p>In other words I want to ingore the NA's similar to how <code>rowSums</code> allows the <code>na.rm=TRUE</code> argument so that I get this result:</p>
  
  <pre><code>  x1 x2 x3 x4
  1  3  4  1 -2
  2  3  3 NA  0
  3  3  2  1  0
  4  3  1 NA  2
  5  3  2  1  0
  6  3  3 NA  0
  7  3  4  1 -2
  8  3  5 NA -2
  </code></pre>
  
  <p>Any help is greatly appreciated.</p>