The newest versions of R packages are often available only as source code. When you install or update the package, it may indicate it needs compilation. To enable your computer to compile the code in these packages, you need to do a small amount of additional setup. Before you start, make sure R is closed. I recommend rebooting after installing, as well, but it is not a requirement.
Mac
On a Mac, you only need to install Xcode Command Line Tools. This is simple:
- Open a terminal window
- Click Spotlight search in the top right of your screen, then search for “Terminal”
- Copy and paste the following into the terminal, then press enter.
xcode-select --install
You will probably need to provide your password to enable installing the software.
Follow any onscreen instructions and wait for it to finish.
You can now compile R packages!
Windows
On a PC, you need to obtain a toolchain for compiling. The easiest way to do this is with RTools:
Download the newest 64-bit Rtools installer.
Run the file to install, following all onscreen instructions. If you are unsure about anything, leave the default settings.
Go back to this page. Follow the remaining instructions. But, first, run
Sys.which("make")
and see if it finds amake.exe
file. If so, you’re good to go. If not, do the path stuff.You can now compile R packages!
Troubleshooting
Compiling code is complicated and sometimes errors specific to your machine will arise even if you followed everything above correctly. Reach out if you have issues!