R install notes for Macintosh Users
The following notes are for installing R, Emacs, and RStudio on MacOS 10.12 (Sierra). We recommend ensuring that your MacOS (Macintosh Operating System) is up to date and that you have no software updates pending before following the steps below (you can open the App Store app on your computer and go to Updates; all the MacOS updates are listed there).
R Install Notes for Macintosh Users
With R versions 3.4.0 and newer, the versions of XQuartz, clang, and gfortran required are not provided by Apple. We also suggest installing the latest version of Xcode (available in the App Store). Without clang or gfortran, packages such as Rstan will not compile properly and will be unusable. This page provides a guide for installing R 3.4.1 and its dependencies. It is TOTALLY FINE if you haven't heard about any of these packages - they usually run behind the scenes. Please and just be patient to follow through the steps listed here, and you will have a more pleasant R learning experience (we promise).
Step 1. Start by downloading and installing "Xcode" from the Apple App Store. This will be a large download (4.54 GB when these instructions were written), therefore this step will take a while and please use Ethernet conection if possible.
Step 2. Go to https://www.xquartz.org/ and download the latest "XQuartz-x.x.xx.dmg" file. Open the .dmg file and double click on the .pkg file to start the installation process. Follow all steps in the installation help window.
Step 3. Navigate to https://cran.r-project.org/. Click on "Download R for (Mac) OS X". Download the R-3.4.1.pkg file, but DO NOT open it yet. We want to install all of the dependencies prior to installing R.
Step 4. Download and Install gfortran:
- Click on the "tools" link in the note for R-3.4.1.
- Click on the "GNU Fortran Binaries" link at the top of the page in the "Important note" paragraph.
- Click on the "MacOS" link towards the top of the page under the "Binaries available for gfortran" section.
- For your OS (macOS Sierra) click on the appropriate "download gfortran x.x" link. Open the downloaded .dmg file and double click on the .pkg file to start the download process. If you open the README.html file you will see instructions telling you to install Xcode first. We already did that in Step 1 so you can proceed to the gfortran installation.
Step 5. Download and Install clang.
- There are two options here. It is possible to use the clang provided by Xcode, however the R core team states: "You can also try to use clang from Xcode, but it will be missing required features so your mileage may vary and it is not recommended." You can skip to Step 6 if you want to use clang from Xcode. If you want to ensure that you have all required features to prevent possible issues in the future, you can follow the steps below.
- We suggest installing Homebrew in order to easily install clang. Navigate to https://brew.sh/.
- At the home page for Homebrew you will see the instructions for quick installation. Open the Terminal app on your Mac and enter the line of code provided on the Homebrew page under the "Install Homebrew" heading.
- If you are unsure of how to open Terminal, try a Spotlight search (Command + Spacebar, then type "Terminal" and hit enter).
- If the Homebrew installation failed (warning messages showed in the terminal), it may be caused by MacOS out-of-date (please make sure to install all the OS updates listed in App Stores).
- Homebrew will go over the installation steps and ask you for your user password to complete the installation.
- Install clang by entering "brew install llvm" in the Terminal and hit enter. This will install llvm, which contains clang.
Step 6. Find the "R-3.4.1.pkg" file which was downloaded in Step 4, double click on it to start the installation process. Follow all steps in the installation help window. Now you have everything you need to run R on your system.
Downloading a User Interface
Once R is installed, we suggest downloading a user interface in which you write your code and run it. Below we provide instructions for Emacs and Rstudio. Rstudio is typically preferred by users new to R, whereas Emacs seems to be more popular among individuals with programming experience.
Emacs install notes for Macintosh users
Applies to: Mac OSX 10.11
We recommend the Emacs install from Vincent Goulet http://vgoulet.act.ulaval.ca/en/home (Note, there may be a newer version).
Locate and double click the downloaded file: Emacs-24.5-1-modified-7.dmg. When the window opens, drag and drop the Emacs icon into the Applications folder.
Browse to your Applications folder and open Emacs.
If a dialog box presents itself asking if you are sure you want to open Emacs, click "Open".
If you get an error that says: "Emacs" is damaged and can't be opened. You should move it to the trash", navigate to the Security and Privacy settings under System Preferences and click: "Allow apps downloaded from: anywhere" (You may have to click the "lock" icon on the bottom left hand corner to type in your password). Then try reopening the Emacs.
RStudio install notes for Macintosh users
Head to https://www.rstudio.com/products/RStudio where you can install a free (open source) version of the desktop software. Download the software.
Double click the download file (.dmg) and drag the RStudio app into the applications folder (as is shown in the Emacs install steps above).