Skip to content

Inconsistencies in sum() (PR#1408)

1 message · Brian Ripley

#
R 1.4.1

sum() tries to keep the result integer, although that is not
currently documented (and I am about to change it).
1) inconsistent in warning or not:
[1] NA
[1] NA
Warning message:
Integer overflow in sum(.); use sum(as.numeric(.))

2) It's order-dependent:
[1] 2147483648
[1] "double"
[1] NA
[1] "double"

I believe that it should calculate in integers only if *all* the
arguments are integers, that is behave like
[1] 2147483648