Open HenrikBengtsson opened 6 years ago
In R-devel svn rev >= 74208 (2018-02-11), y <- base::sum(x) will now return mode(y) = "numeric" in case y > 2^31-1. See also the R-devel thread 'sum() returns NA on a long logical vector when nb of TRUE values exceeds 2^31' started on 2017-06-02 for the reasons behind this.
y <- base::sum(x)
mode(y) = "numeric"
y > 2^31-1
Add option for sum2() to emulate this new behavior. This could be done as:
sum2()
y <- matrixStats::sum2(x, mode = "sufficient")
or mode = "coerce", mode = "agile", or similar. An alternative could be to introduce a new argument onOverflow = "numeric".
mode = "coerce"
mode = "agile"
onOverflow = "numeric"
What the default behavior should be can be discussed later; I don't think it affects the decision to implement this feature or not.
Background
In R-devel svn rev >= 74208 (2018-02-11),
y <- base::sum(x)
will now returnmode(y) = "numeric"
in casey > 2^31-1
. See also the R-devel thread 'sum() returns NA on a long logical vector when nb of TRUE values exceeds 2^31' started on 2017-06-02 for the reasons behind this.Suggestion
Add option for
sum2()
to emulate this new behavior. This could be done as:or
mode = "coerce"
,mode = "agile"
, or similar. An alternative could be to introduce a new argumentonOverflow = "numeric"
.What the default behavior should be can be discussed later; I don't think it affects the decision to implement this feature or not.