Below is some further troubleshooting on this:
>From code inspection this bug happens for only:
* for integer values
* when the first element is NA_integer_ and the second is not.
Examples:
# Numeric/doubles works as expected
> cummax(c(NA_real_, 0, 1, 2, 3))
[1] NA NA NA NA NA
# It does not
Hi,
The function cummax() seems to have a bug.
> x <- c(NA, 0)
> storage.mode(x) <- "integer"
> cummax(x)
[1] NA 0
The correct result of this case should be NA NA. The mistake in [
https://github.com/wch/r-source/blob/trunk/src/main/cum.c#L130-L136] may be
the reason.
Best Regards,
Dongcan
--