How to Update R and RStudio on Mac OS X

Because R and R Studio don’t necessarily warn you when they need upgrading, I had to figure it out myself when I started getting some weird bugs running assignments during an R class. Alas, I needed to update R to the latest version, and in the process decided to update RStudio as well. Here is how I went about it.

t’s important to first check the R version. You can either just look at the top comment when you load R Console or R Studio:

You can also run the following command in the R console or in RStudio which will give you a lot more information:

R.Version()

The two main things you’re looking for when you run R.Version() are:

major – the major version number
and
minor – the minor version number, including the patch level

Of course to check what your R Studio version is you just need to click on the Help menu item and then click on “About RStudio”.

To update R, go to CRAN and download the latest version and run the install.  When you restart RStudio or R Console it should automagically detect and use the new R version.  You can manually change what version of R your RStudio is using at any time. See the note at the end of this post.

To update RStudio, go to the RStudio website and download the latest version for Mac. Once it’s downloaded, drag it into Applications folder (that’s how it is at the time of this posting) and allow it to replace your existing RStudio version.

That’s pretty much all you need to do. To be double sure you can click on Help -> Check for Updates to make sure you’re on the latest version of RStudio.

NOTE: When you update R, the older versions are not deleted, so you can have different versions of R installed side by side on your system. To see what versions of R are installed on your Mac, open terminal and run the following command:

ls -l /Library/Frameworks/R.framework/Versions/

The output of this command should be a list of the R versions on your system, assuming you install R to the default location. Mine looks something like this:

To change which version of R RStudio uses you can use the RSwitch utility (found here). I haven’t tried this yet so can’t speak to how or whether it works. I prefer to use the symlink method using the ln -s command. For example the following command will make RStudio use the version of 3.3 that’s on my Mac.  You can switch 3.3 out with whatever version you want as long as it’s listed as being installed on your Mac when you run the ln -l command I gave above.

ln -sfhv /Library/Frameworks/R.framework/Versions/3.3 /Library/Frameworks/R.framework/Versions/Current

 

Fair warning: This ln -s command seems to break R Console, but R Studio continues to work fine, and that’s what I use most times anyway. I’m not entirely sure how to do this for R console, but if I do find out I will update this post.

Hope this is helpful for someone.

Leave a Reply