From lukas.stadler at oracle.com  Fri Jan 20 14:52:01 2017
From: lukas.stadler at oracle.com (Lukas Stadler)
Date: Fri, 20 Jan 2017 14:52:01 +0100
Subject: [Rd] NaN behavior of cumsum
Message-ID: <9A7219BE-A728-45E0-B02E-E1834841D749@oracle.com>

Hi!

I noticed that cumsum behaves different than the other cumulative functions wrt. NaN values:
> values <- c(1,2,NaN,1)
> for ( f in c(cumsum, cumprod, cummin, cummax)) print(f(values))
[1]  1  3 NA NA
[1]   1   2 NaN NaN
[1]   1   1 NaN NaN
[1]   1   2 NaN NaN

The reason is that cumsum (in cum.c:33) contains an explicit check for ISNAN.
Is that intentional?
IMHO, ISNA would be better (because it would make the behavior consistent with the other functions).

- Lukas


[Rd] NaN behavior of cumsum
Lukas Stadler