I have noticed that if I have a number larger than 10 digits, the as.integer function will return NA.
For example:
as.integer(10000000000)
will give NA.
Why does this happen? I guess it might have something to do with the storage of integers? How can I work around this issue?
Thanks.
You can find the limit for integers by:
> .Machine$integer.max
[1] 2147483647
Any bigger values will be interpreted as NA
> as.integer(.Machine$integer.max)
[1] 2147483647
> as.integer(.Machine$integer.max+1)
[1] NA
Warning message:
NAs introduced by coercion to integer range 
If you need to handle bigger values, either use as.numeric (numerics can handle bigger values than integers) or a package like gmp (Multiple Precision Arithmetic package).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With