简体   繁体   中英

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 (eg for adaptive .Rprofile files)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM