Hi Lukas,
thanks for the report. I've changed cumsum so that it is now consistent
with cumprod wrt to NA/NaN propagation.
Now NaN is not turned into NA unnecessarily.
Still please be aware that generally NaNs may become NAs in R (on some
platforms/compilers)
?NaN says
"Computations involving ‘NaN’ will return ‘NaN’ or perhaps ‘NA’:
which of those two is not guaranteed and may depend on the R
platform (since compilers may re-order computations)."
Best
Tomas
On 01/20/2017 02:52 PM, Lukas Stadler wrote:
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
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel