Moody_Mudskipper Moody_Mudskipper - 3 years ago 127
R Question

Predefined constant for maximum integer

Doc

?integer
says:


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


Is there a defined constant that holds this value ?

My use would be for
match
. I can't do
match(x,y,nomatch=Inf)
because
nomatch
will be coerced to
integer
(so
Inf
coerced to
NA
). And I'd rather write
match(x,y,max_int)
(with a documented constant) than
match(x,y,2*10^9)
.

Answer Source

Try:

?.Machine

.Machine is a variable holding information on the numerical characteristics of the machine R is running on, such as the largest double or integer and the machine's precision.

In your case, you could use:

.Machine$integer.max

which returns:

2147483647
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download