Download PDF
Download page Installing and Configuring R and RStudio.
Installing and Configuring R and RStudio
Installing R
From the App Portal
Search in the App Portal for "r foundation r for windows" and sort by newest first. Searching just for "r" is going to be frustrating. As of version 4.4.3 is the most recent version on the App Portal and this is the most recent version of R. Note: it can take 2 or more days for requested apps to be installed, so please do this well in advance of class!
Installing RStudio
From the App Portal
Search in the App Portal for "Posit RStudio" and sort by newest first. As of v ersion 2024.12.1-563 is the most recent version on the App Portal and this is the most recent version of RStudio. If you find a more recent version you can use that if you like. Note: it can take 2 or more days for requested apps to be installed, so please do this well in advance of class!
Configuring RStudio and Installing Libraries
Configuring RStudio
If you used the App Portal to install RStudio, you can access it in the Start menu.
RStudio should automatically detect your installation of R. You should see text in the console that indicates which version of R is running:
Only if RStudio does not detect your installation of R, go to the Tools menu and select Global Options. On the first window (General) select the R version by hitting the Change button towards the top:
The "Use your machine's default 64-bit version of R" option usually works, but if not, use the "Choose a specific version of R" option and choose the most recent version from the list below:
Click OK and OK to exit. You will need to restart RStudio for the changes to take effect.
Configuring CRAN Mirror
CRAN (Comprenhensive R Archive Network) is a network of ftp and web servers around the world that store identical, up-to-date, versions of code and documentation for R. RStudio looks to CRAN to to find installation packages for R. Some USACE computers are restricted in terms of which network locations can be accessed for these packages. We will set RStudio so that it looks for a CRAN mirror inside the United States which usually causes fewer problems.
Open the options menu in RStudio by going to the Tools menu, then Global Options at the very bottom.
Then on the left side menu, select Packages.
Under Package Management, Primary CRAN repository, press the "Change..." button. It will then get the list of available CRAN mirrors which may take a few seconds. Scroll down until you find a site in the United States, for example, Iowa State University in Ames, IA. Select it, and press OK.
In the Options window, press Apply, then OK to exit.
Installing Libraries
The main source of R's power is in its libraries. These libraries are free, publicly-available extensions of R. RStudio has a simple interface for installing and managing packages. In the lower-right pane of RStudio, make sure the Packages tab is selected.
Click the "Install" button in the upper left. In the box that pops up, use the text field to enter three package names: tidyverse
, GGally
, and car
as shown below. These packages are used in the Multiple Linear Regression Using R workshop. You can install other packages in this same way if you like. Other workshops will require you to install other packages.
Package names are case-sensitive, but sometimes RStudio is able to help you out and install the correct package regardless of case.
The package manager also has an autocomplete function, where it can suggest a package based on what you've typed in. It will give you a list of matching packages after you type a couple of characters in the Packages box. The pattern matching doesn't care about case so you can use it to find your package if you're unsure of capitalization.
RStudio will install those three packages, and all their dependencies (there are a lot). The process could take a minute or two.
Once once all the noise is finished, go back to the Packages tab and click the Update button. This will ensure all installed libraries are up to date. A new window showing available updates will pop up, and the list should be short. An example is below, but your list may look different.
Click "Select All" then "Install Updates." RStudio will install them automatically. If your list is short this process should be quick.