Optional: Installing R and RStudio
For our class we do not need to install R and RStudio as we will be using the CSUMB Cal ICOR Hub R Server.
After you leave CSUMB, though, you will want to be able to access R and RStudio on your own computer. We are going to learn about / refresh our memory on R and RStudio to make sure you have a local installations of both R and RStudio on your computer.
Step 1: Installing R
As mentioned above, you will need to have local installations of both R (the software) and RStudio (the interface for working in R). Do not skip this step if you already have both R and RStudio installed on your computer, as you need to ensure you are using the most up to date version of R and RStudio.
Updating Your Version of R
If you already have R
downloaded, you need to confirm that you have the most up to date version of R
. Do not ignore these instructions. If you neglect to update your version of R, you may find that updating a package will make it so your code will not run.
- Step 1: Open RStudio
- Step 2: At the top of the the Console it will say what version of R you are using
If the version is not 4.5.1 (like the image above), you need to update your version of R! The simplest way to do this is to follow the instructions below to install R.
Installing R
Download and install R by going to https://cloud.r-project.org/. Here, you will find three options for installing R—click on the option for your computer’s operating system.
📽️ Useful Video: Installing R and RStudio - Windows
📽️ Useful Video: Installing R and RStudio - Mac
If you are a Windows user:
Click on “Download R for Windows”
Click on “base”
Click on the Download link.
When you open the execution file (
.exe
) you will be prompted with a variety of questions about installing R. Feel free to use the default features / settings that come with R (continue to click “Ok” until the download starts).
Beware that if you had a previous version of R downloaded on your PC, that old version will not be deleted when you download the most recent version of R. We do not want to have two versions of R installed, as your computer can get confused what version of R to use. So, you need to remove the old version of R.
To do this you need to:
- Navigate to your computer’s settings
- Click on the “Apps” option on the left-hand panel
- Search for or scroll down to R
- Find the older version of R
- Click on the
...
on the right side - Select “Uninstall”
If you are macOS user:
Click on “Download R for (Mac) OS X”
Under “Latest release:” click on R-X.X.X.pkg, where R-X.X.X is the version number. For example, the latest version of R as of October 31, 2024 was R-4.4.2 (Pile of Leaves).
When installing, use the default features / settings that come with R (click Ok until the download starts).
First, identify which version of OSx you are running. How-to
Next, find out which version of R
your computer can run. Link
If this version is 3.6 or later, download the latest version that your computer can handle.
If this version is 3.4 or earlier, you’re going to run in to some trouble. I recommend updating your version of OSx, if you are willing. If you can’t, then you can use Posit Cloud to run R
and RStudio on a free server. However, I recommend strongly against this option; your files will not be saved indefinitely, you will have limited hours to complete your work, your computing power will be limited, and you will need an internet connection at all times to do your work.
If you are a Linux user:
Click on “Download R for Linux” and choose your distribution for more information on installing R
for your setup.
Step 2: Install RStudio
RStudio is an Integrated Development Environment (IDE) for R
. What does that mean? Well, if you think of R
as a language, which it is, you can think of RStudio as a program that helps you write and work in the language. Back in the dark ages, people wrote programs in text editors and then used the command line to compile those programs and run them. RStudio makes programming in R
much easier and this course requires you to use it!
Updating Your Version of RStudio
If you already have RStudio, you need to double check if you have the most recent version. You will not have access to the newest features for Quarto documents unless you have the most recent version of RStudio.
- Step 1: Open RStudio
- Step 2: Click on “Help” in the upper menu
- Step 3: Click on “Check for Updates”
If there are no updates to RStudio since you installed it, you are good to go! If you need to update RStudio, you will be sent to Posit (the parent company) to download the most recent version of RStudio desktop.
Installing RStudio
Downloading the most recent version of RStudio works the same way regardless of whether you’ve never downloaded RStudio before or if you just need to update your version of RStudio.
When you navigate to the RStudio download page (https://rstudio.com/products/rstudio/download/), the website should automatically detect your computer’s operating system. So, you should be able to simply click the blue “Download RStudio Desktop for [insert operating system here]” button.
Clicking the button will begin installing RStudio. Once the download has completed, you will need to open the application file (on a Mac this is a .dmg
file, on Windows this is an exe
file).