Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In R, what's the canonical way to detect if the OS is 64-bit?

Some possibilities include:

Sys.info()["machine"] == "x86-64"
.Platform$r_arch == "x64"
version$arch == "x86_64"

Is there any reason to prefer one method over another?

Related: detecting operating system in R (e.g. for adaptive .Rprofile files)

like image 869
Richie Cotton Avatar asked Jun 22 '12 15:06

Richie Cotton


1 Answers

Actually none of those methods would be canonical, which I take to mean "what would Brian Ripley say". Try this:

?.Machine

sizeof.pointer........the number of bytes in a C SEXP type. Will be 4 on 32-bit builds and 8 on 64-bit builds of R.

 64bit <- .Machine$sizeof.pointer == 8
 64bit
 #[1] TRUE

As for your nominations only one of them returns TRUE on my machine:

> Sys.info()["machine"] == "x86-64"
machine 
  FALSE 
> .Platform$r_arch == "x64"
[1] FALSE
> version$arch == "x86_64"
[1] TRUE
like image 77
IRTFM Avatar answered Nov 12 '22 08:11

IRTFM