Skip to content
Prev 317703 / 398506 Next

Handling NA values

On Feb 16, 2013, at 11:55 AM, Christofer Bogaso <bogaso.christofer at gmail.com> wrote:

            
The result of:

  sum(c(NA, NA), na.rm = TRUE)

is to sum an empty set, hence the 0.
logical(0)
attr(,"na.action")
[1] 1 2
attr(,"class")
[1] "omit"
[1] 0


If you retained the NA's, then the result is undefined:
[1] NA


See:

  http://rwiki.sciviews.org/doku.php?id=tips:surprises:emptysetfuncs

for more information.

Regards,

Marc Schwartz