Step 1: Install R and RStudio
Step 1 of 5
Before you start: the laptop you will bring to IISc, and administrator rights on it. When you finish: R and RStudio are installed and working together.
You are installing 2 programs. R does the work. RStudio is the window you look at it through. Install R first.
There are 5 things to do on this page. You can skip the fourth if you have never used R on this laptop.
You may not have them on an institutional laptop. Find out this week, not on Sunday night. If you cannot install software yourself, send this page to your IT department today.
1. Install R
- Go to cran.r-project.org.
- Click the link for your operating system.
- Windows: click base, then the download link. Run the
.exe. Accept every default. - macOS: click the
.pkgfor your chip. Apple Silicon (M1, M2, M3, M4) needs the arm64 build. Older Intel Macs need the plain one. - Linux: follow the CRAN instructions for your distribution.
You should see: an installer that finishes with no error box.
If it does not work: install into the default location. A folder path with spaces or non-English characters in it breaks package installs later.
Click the Apple menu, then About This Mac. Read the Chip line.
2. Check that R opens
- Open R on its own. On Windows, choose R x64 from the Start menu. On macOS, open
R.app. - Read the first line in the console window.
You should see: a version number of 4.1.0 or higher.
If it does not work: go back to 1 above. Do not go on until R itself opens.
3. Install RStudio
- Go to posit.co/download/rstudio-desktop.
- Download the installer the page offers you.
- Run it. Accept the defaults.
You should see: RStudio open, with the Console filling the left-hand side. It shows the same R version you read in 2 above. (You will see 3 panes until you open a file, and 4 after that.)
If it does not work: if the console says R is missing, close RStudio. Check that R itself opens. Then install RStudio again.
Updating one does not update the other. When you update, you have 2 things to update.
4. Point RStudio at the right R
Skip this step if you have never used R on this laptop.
More than one R can be installed at once. Check which one RStudio picked.
- In RStudio, click Tools → Global Options → General.
- Read the R version line at the top.
You should see: the R you installed in 1 above.
If it does not work: click Change, choose the right R, then restart RStudio.
5. Test the pipe
- Click once inside the Console pane, on the left.
- Type
c(1, 2, 3) |> sum()and press Enter.
You should see: [1] 6.
If it does not work: an error here means your R is older than 4.1.0. Go back to 1 above.
RStudio looks for R when it starts. Install them the other way round and RStudio reports that R is missing, even when it is not.
|> is the pipe, and it only exists in R 4.1.0 and newer. So typing it is a better version check than reading a version number: if [1] 6 comes back, your R is new enough for everything on this course.