title: Element-wise mean in R
body: <p>In R, I have two vectors:</p>
  
  <pre><code>a &lt;- c(1, 2, 3, 4)
  b &lt;- c(NA, 6, 7, 8)
  </code></pre>
  
  <p>How do I find the element-wise mean of the two vectors, removing NA, without a loop? i.e. I want to get the vector of </p>
  
  <pre><code>(1, 4, 5, 6)
  </code></pre>
  
  <p>I know the function <code>mean()</code>, I know the argument <code>na.rm = 1</code>. But I don't know how to put things together. To be sure, in reality I have thousands of vectors with NA appearing at various places, so any dimension-dependent solution wouldn't work. Thanks.</p>