Installing R and RStudio

Mac Users

To install R

  1. Open an internet browser and go to www.r-project.org.
  2. Click the “download R” link in the middle of the page under “Getting Started.”
  3. Select a CRAN location (a mirror site) and click the corresponding link.
  4. Click on the “Download R for (Mac) OS X” link at the top of the page.
  5. Click on the file containing the latest version of R under “Files.”
  6. Save the .pkg file, double-click it to open, and follow the installation instructions.
  7. Now that R is installed, you need to download and install RStudio.

To install RStudio

  1. Go to www.rstudio.com and click on the “Download RStudio” button.
  2. Click on “DOWNLOAD” in the upper right corner.
  3. Download the Free version of RStudio Desktop.
  4. Save the .dmg file on your computer, double-click it to open, and then drag and drop it to your applications folder.

Windows Users

To install R

  1. Open an internet browser and go to www.r-project.org.
  2. Click the “download R” link in the middle of the page under “Getting Started.”
  3. Select a CRAN location (a mirror site) and click the corresponding link.
  4. Click on the “Download R for Windows” link at the top of the page.
  5. Click on the “install R for the first time” link at the top of the page.
  6. Click “Download R for Windows” and save the executable file somewhere on your computer. Run the .exe file and follow the installation instructions.
  7. Now that R is installed, you need to download and install RStudio.

To install RStudio

  1. Go to www.rstudio.com and click on the “Download RStudio” button.
  2. Click on “DOWNLOAD” in the upper right corner.
  3. Download the Free version of RStudio Desktop.
  4. Save the executable file. Run the .exe file and follow the installation instructions.

Permissions
Note that you should install R and RStudio to a drive where you have read and write permissions. Otherwise, your ability to install R packages (a frequent occurrence) will be impacted. If you encounter problems, try opening RStudio by right-clicking the icon and selecting “Run as administrator”. Other tips can be found in the page [R on network drives].

How to update R and RStudio

Your version of R is printed to the R Console at start-up. You can also run sessionInfo().

To update R, go to the website mentioned above and re-install R. Be aware that the old R version will still exist in your computer. You can temporarily run an older version (older “installation”) of R by clicking “Tools” -> “Global Options” in RStudio and choosing an R version. This can be useful if you want to use a package that has not been updated to work on the newest version of R.

To update RStudio, you can go to the website above and re-download RStudio. Another option is to click “Help” -> “Check for Updates” within RStudio, but this may not show the very latest updates.

Reference

Instructions adapted from guide developed by HMS Research computing and Chapter 3 of the The Epidemiologist R Handbook.