title: R - Convert NA to NaN
body: <p>I have three columns in a data frame that I want to average together. The problem is, in one of the columns, some spaces read "NA". The data set I'm working with is quite large, but I'll simplify it with the below example:</p>
  
  <pre><code>a &lt;- c(1,2,3,4)
  b &lt;- c(2,3,4,5)
  c &lt;- c(3,NA,NA,6)
  df &lt;- data.frame(a,b,c)
  df$mean &lt;- (df$a + df$b + df$c)/3
  df
  
    a b  c mean
  1 1 2  3    2
  2 2 3 NA   NA
  3 3 4 NA   NA
  4 4 5  6    5
  </code></pre>
  
  <p>I would like to format <code>df$c</code> so that the <code>NA</code>'s are replaced with something innocuous, like <code>NaN</code>, or any other value that would be ignored by the average operation while still holding a place in the data frame. If there would be another way to get the <code>NA</code>'s in column C ignored, I'd be happy. </p>