Installing R/RStudio on a Mac

Nov 16, 2019 Mac R

Before you install R Stuff.

Follow the instructions in my post called Configure A Mac for Data Science before you install any R stuff.

What are R, R Studio Desktop and R packages

R, R Studio Desktop and R packages are software programs made and supported by many different people. You can learn more about R, and the people that currently curate it, on Wikipedia. R Studio Desktop is an “Integrated Development Environment”, which makes it possible to use point and click tools to see your work, made by a company called R Studio. While there are some companies that add to R for a fee, most R packages are made by random individuals scattered across the globe who just like to solve problems.

Think of R as the engine that powers your analysis. R Studio Desktop is the rest of the car that you get from the dealer. R packages are the after sales bling that you add on to make your car special.

First install R and XQuartz

You can get the latest release of R from here. On November 16, 2019 the latest release was 3.6.1.pkg. R updates several times a year. “Patch” updates will cause the x.x.1 to change to another number. “Minor” updates, which change the x.6.x to a new number, happen in April of every year. Major updates to R are rare (Version 2.0.0 came out in 2004, 3.0.0 was in 2013) but the next (not patch) update to R will be 4.0.0.

There are a few useful R addon packages that will want to use an ancient set of tools for drawing windows called “X11”. So, after you install R itself grab the X11 tools that are in XQuarts. There is a link on that R install page or you can jump to the XQuarts installer here.

What did it install

When you install R you are getting a big pile of files. You don’t need to know the details but if you are the curious type… the files are getting stashed in a Versions subfolder buried deep inside your Library folder:
Image of Versions folder.

Figure 1: Image of Versions folder.

I mention this because, as you can see in Figure 1, I have both version 3.5 and 3.6 on my machine. If you are working on an ancient laptop that has no room, be sure to delete the old version of R before you install an update. R itself is not huge but you may end up using many add on packages and they can eat up drive space. As you can see in Figure 2 I have managed to collect 1.62 GB of packages for version 3.6 and I have a lot of stuff in the version 3.5 folder as well.

Image of 1.62 GB of packages in the libraries.

Figure 2: Image of 1.62 GB of packages in the libraries.

Next Install R Studio Desktop

R Studio Desktop can be downloaded from here. After you install it, you will want to make a couple changes to your configuration.

General Options

Choose Global Options… from the RStudio Tools menu.

Image of Global Options menu item

Figure 3: Image of Global Options menu item

Once you are there, in the Workspace section, uncheck the Restore .RData into workspace at startup checkbox and set the Save workspace to .RData on exit to be Never

Image of Workspace options in the General windowpane

Figure 4: Image of Workspace options in the General windowpane

Code Options

Next click on the Code windowpane and then click the Display tab from the tabgroup at the top of the screen. Check on the box to Show margin and make sure the Margin column is set at 80 characters.

Image of the Code options windowpane after clicking the Display

Figure 5: Image of the Code options windowpane after clicking the Display

Later, when you write code, this option will put a thin gray line on the right margin of the screen when you write code. It will help to remind you to keep your lines of code short enough to read. I will say more about that later.