Installing R and RStudio
Mac Users
To install R
- Open an internet browser and go to www.r-project.org.
- Click the “download R” link in the middle of the page under “Getting Started.”
- Select a CRAN location (a mirror site) and click the corresponding link.
- Click on the “Download R for (Mac) OS X” link at the top of the page.
- Click on the file containing the latest version of R under “Files.”
- Save the .pkg file, double-click it to open, and follow the installation instructions.
- Now that R is installed, you need to download and install RStudio.
To install RStudio
- Go to www.rstudio.com and click on the “Download RStudio” button.
- Click on “DOWNLOAD” in the upper right corner.
- Download the Free version of RStudio Desktop.
- 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
- Open an internet browser and go to www.r-project.org.
- Click the “download R” link in the middle of the page under “Getting Started.”
- Select a CRAN location (a mirror site) and click the corresponding link.
- Click on the “Download R for Windows” link at the top of the page.
- Click on the “install R for the first time” link at the top of the page.
- Click “Download R for Windows” and save the executable file somewhere on your computer. Run the .exe file and follow the installation instructions.
- Now that R is installed, you need to download and install RStudio.
To install RStudio
- Go to www.rstudio.com and click on the “Download RStudio” button.
- Click on “DOWNLOAD” in the upper right corner.
- Download the Free version of RStudio Desktop.
- 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.