How do I replace all NA with mean in R?
<p>I have over 1500 columns in my dataset and 100+ of them contains at least one NA. I know I can replace NAs in a single column by</p>

<pre><code>d$var[is.na(d$var)] &lt;- mean(d$var, na.rm=TRUE)
</code></pre>

<p>but how do I do this too ALL the NAs in my dataset?</p>

<p>Thank you!</p>