Difference between na.rm = TRUE and na.action = na.omit in aggregate()
<p>I had a dataset with NA values in there randomly, and when I use this:</p>

<pre><code>aggregate(y2_predict[,15:17], list(Name=y2_predict$Name), mean, na.action = na.omit)
</code></pre>

<p>It gives something like this:</p>

<pre><code>Name var1 Var2 Var3 
1999  NA    NA
2000 NA NA
2001 NA NA
</code></pre>

<p>But if I use this:</p>

<pre><code>aggregate(y2_predict[,15:17], list(Name=y2_predict$Name), mean, na.rm = TRUE)
</code></pre>

<p>Then it returns something like this</p>

<pre><code>Name var1 Var2 Var3 
1999  2    3.5
2000 5.2 6
2001 7 8
</code></pre>

<p>Apparently the first one does not work and the second one does. But I keep thinking they're mostly the same -- ignore NAs, or remove NAs ---neither of them should include NAs when calculating means by group. Then why is the first one not working? I am just making sure I'm not missing anything and I'm doing things correctly. Thanks.</p>