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:
install.packages() refuse to get binaries from CRAN when running in a non-official R distribution? I assume there is some concern about binary compatibility, and I am looking to gain some technical insight into the reason for that.install.packages() tell whether binaries can be used or not?install.packages()?From the docs in ?install.packages regarding the type parameter:
Possible values of
typeare (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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With