How to ignore NA when using mean?
<p>1) </p>

<pre><code>x=2;y=3
mean(x,y)
#[1] 2
</code></pre>

<p>I am surprised why 2. It should be 2.5!</p>

<p>2) </p>

<pre><code>x=c(2,5,NA)
y=c(3,NA,NA)
mean(x,y,na.rm=TRUE)
Error in mean.default(x, y, na.rm = TRUE) : 
  'trim' must be numeric of length one
</code></pre>

<p>I want to compute the mean between <code>x</code> and <code>y</code>. When there is <code>NA</code>, just put the other value.</p>

<p>desired output:</p>

<pre><code>2.5 5 NA
</code></pre>