Course website for CSSS508: Introduction to R for Social Scientists
University of WashingtonThe 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.
On a Mac, you only need to install Xcode Command Line Tools. This is simple:
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.
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 a make.exe
file. If so, you’re good to go. If not, do the path stuff.
You can now compile R packages!
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!