Szabolcs
Szabolcs

Reputation: 25703

What determines CRAN binary compatibility?

CRAN has binary versions of packages for Windows and macOS. However, install.packages() will only use these when running in the official CRAN R distribution. If one uses a different R distribution (e.g. from Homebrew or MacPorts on macOS) or compiles R from sources oneself, then install.packages() will not download binaries and will instead compile all packages from sources.

Questions:

Upvotes: 4

Views: 277

Answers (1)

Allan Cameron
Allan Cameron

Reputation: 174393

From the docs in ?install.packages regarding the type parameter:

Possible values of type are (currently) "source", "mac.binary", and "win.binary": the appropriate binary type where supported can also be selected as "binary".

The default setting for type is getOption("pkgType"). This option seems to be defaulted to "source" in non-CRAN builds, and if you try to set the option to "both", (which would be the default on CRAN builds), then install.packages will complain. You could set the option to "mac.binary", or bypass the options altogether by using the type parameter.

So, to install the latest MacOS binary for, say, dplyr, you could do:

install.packages("dplyr", type = "mac.binary")

or

options(pkgType = "mac.binary")

install.packages("dplyr")

Note this will also install the dependencies of the installed package.

Upvotes: 4

Related Questions