Skip to content
Prev 326961 / 398502 Next

Errors using large numbers ((i) all entries of 'x' must be nonnegative and finite and (ii) NAs introduced by coercion)

HI,
?as.integer() #documentation
Note that current implementations of R use 32-bit integers for
???? integer vectors, so the range of representable integers is
???? restricted to about +/-2*10^9: ?double?s can hold much larger
???? integers exactly.
as.numeric(c(75533, 4756922556, 88210, 6715122129))
#[1]????? 75533 4756922556????? 88210 6715122129
#or
?as.double(c(75533, 4756922556, 88210, 6715122129))
#[1]????? 75533 4756922556????? 88210 6715122129
A.K.





----- Original Message -----
From: PIKAL Petr <petr.pikal at precheza.cz>
To: jgibbons1 <jgibbons at hsph.harvard.edu>; "r-help at r-project.org" <r-help at r-project.org>
Cc: 
Sent: Tuesday, July 16, 2013 12:54 PM
Subject: Re: [R] Errors using large numbers ((i) all entries of 'x' must be nonnegative and finite and (ii) NAs introduced by coercion)

Well,

You could find it yourself,

as.integer(c(75533, 4756922556, 88210, 6715122129))
[1] 75533? ? NA 88210? ? NA
Warning message:
NAs introduced by coercion
? ? ? ? ?  [,1]? ? ?  [,2]
[1,]? ? ? 75533? ? ? 88210
[2,] 4756922556 6715122129

Using as.integer inputs NA as integer type has limited size.

Petr
______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.