Message-ID: <76173CC7-C49D-464C-9B12-13EF8A8E94B4@xs4all.nl>
Date: 2013-02-16T18:09:38Z
From: Berend Hasselman
Subject: Handling NA values
In-Reply-To: <CA+dpOJmL7P=TY8yApz0+r62_xhjvXfRnpPa+64=t87TA8yaGqw@mail.gmail.com>
On 16-02-2013, at 18:55, Christofer Bogaso <bogaso.christofer at gmail.com> wrote:
> Hello again,
>
> I have a question on who sum() handle the NA values.
>
>> sum(c(NA, 1), na.rm = TRUE)
> [1] 1
>
>
> I understand this. However could not agree with following:
>
>> sum(c(NA, NA), na.rm = TRUE)
> [1] 0
>
>
> Where this '0' is coming from? Should not it be NA itself?
sum(c())
[1] 0
>> sum(c(NA, NA), na.rm = TRUE)
is equivalent to sum(c()) or sum(NULL) or sum(integer(0).
See the NB in the value section of the help page for sum.
Berend