How to install R and RStudio

Niels Schwab | Johannes Weidinger | Maria Bobrowski | Charlotta Mirbach
RLab - Skriptbasierte modulare Umweltstatistik (Universitätskolleg 2.0)
Universität Hamburg
CC BY-SA 4.0 | 2019

Content overview

Goal and Basics

This is a guide to installing R (statistics program) and its 'control software' RStudio to your hard drive or external storage.

Time required: approximately 30 minutes.

Please install both programs before attending any RLab classroom session and bring your hard drive or external storage.

Please use a Windows OS (tutorial for Mac at the end of this document). You will need admin rights to the computer, so installation won't be possible on most UHH computers. Using the program on your hard drive is possible, however, as well as using the pre-installed version on our UHH computers - please note, that this version might not be the latest one.

At RLab, we use the "portable" version of R, because unlike the "normal" program version, this version also works correctly on computers that are located in a special network architecture, as is the case in some computer rooms of the university. As of recently, there is only one "normal" version of RStudio, which can also be installed on a USB stick. With this "combination" of the "portable" R version and the "normal" version of RStudio, you can be sure that the programs on the USB stick or hard drive can be used on any Windows computer.

In the context of RLabs, the "portable" R version has no disadvantages. Among other things, when processing large amounts of data or other computing-intensive tasks, it can be advantageous to use only the "normal" versions of R and RStudio.

In the following, we point out the alternative installation options for the "normal" R version at the appropriate points.

Info for Mac users:
Rlab does not offer a guide for R and RStudio on a Mac, at the moment. This is due to a lack of routine with working on Mac in our team. We can therefor not guarantee to sufficiently teach beginners with no previous knowledge of R and RStudio. If you have no access to a Windows computer, you can look into solutions for running windows on a Mac online.
There are R and RStudio version for Mac and you may use them 'at your own risk'. Please note that you should install XQuartz when using Mac since it is not part of OS X.
Learn more about using R and RStudio on Mac OS X here.

Download R and RStudio

First you will need to install RStudio ('control software') to your hard drive or external storage. From now on we will only use the term hard drive, referring to both USB drives and external storages. An external storage is preferable due to larger storage capacity. You can download RStudio for free online.

  1. Identify your hard drive (which drive letter assignment? In this screenshot it's D: and clean up a little if needed. You may store other files on your hard drive, but R and RStudio should preferably be installed to the top level folder of your hard drive. You should at least have 4 GB storage capacity, preferably more. In your top level folder create a new folder called 'R'.

empty harddrive

Fig. 1: Empty harddrive.

  1. Go to the https://www.rstudio.com/products/rstudio/download/ page. (Search term for search engine: "download rstudio")

URL RStudio

Fig. 2: URL RStudio.

  1. On the next page, click on the installation file (.exe). The download will start shortly.

latest version of RStudio

Fig. 3: Rstudio paf.exe.

  1. Wait until the application is ready for download. Save the application to the folder 'R' which you have created in step 1. In case your browser settings don't allow for choosing your storage location, it will automatically saved to a preset folder such as your 'Downloads' folder. In this case just copy the file to your hard drive after the download is complete.

RStudio save as

Fig. 4: RStudio save as.

  1. This is how your hard drive should look after successfully downloading R-Studio.

R folder after successful download

Fig. 5: R folder after successful download.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!

Installing RStudio

Goal: Installation of RStudio - this application 'controls' the statistics program R.

  1. Run „RStudio_1.0.143.exe“ (double click the file; version numbers might change)

  2. Select the language of the installation dialogue

RStudio language selection

Fig. 6: RStudio language selection.

  1. Start installation assistant.

RStudio installer

Fig. 7: RStudio installer.

  1. Select the target directory for the installation. Do not use the default setting. Select the folder"R Studio" within your folder "R" on your hard drive as the target directory for RStudio.

RStudio desired location

Fig. 8: RStudio desired location.

  1. Once you have selected the target directory, click "install". Installation may take several minutes.

RStudio location and installation

Fig. 9: RStudio location and installation.

  1. After successful installation, click "Finish", and ….

RStudio installation complete

Fig. 10: RStudio installation complete.

  1. …your hard drive should look like this now.

RStudio hard drive final

Fig. 11: RStudio hard drive final.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!

Download R

Goal: Download R (the actual statistics program) to your hard drive. Like RStudio, R is an open source software.

  1. Click on this link https://sourceforge.net/projects/rportable/files/R-Portable/ (If you're using a search engine, look for 'download windows R portable')

URL download R

Fig. 12: URL to download R.

Non-portable version
If you wish to use the 'normal' version later on, you can find it here https://cran.r-project.org/bin/windows/base/. But this is not relevant at the moment. Installation of the 'normal' version is very similar. When you install the 'normal' version you will be able to choose where R shall be installed.

  1. Select the latest R version for windows.

select latest R version

Fig. 13: Select latest R version.

  1. Wait until the application is ready for download. Save the application to the folder 'R' on your hard drive. In case your browser settings don't allow for selecting a target directory, it will automatically be saved a preset folder such as your 'Downloads' folder. In this case just copy the file to your hard drive after the download is complete.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!

Installation of R

Goal: Installation of the statistics program R. It will later be 'controlled' by the previously installed RStudio.

  1. Installation of R is very similar to installing RStudio. Run the downloaded .exe file with a double click and follow the installation assistant.

USB after download

Fig. 14: USB after download.

  1. Select the target directory for the installation. Do not use the default setting. Select the folder "R" on your hard drive as the target directory for RStudio.

Choose target directory

Fig. 15: Choose target directory.

  1. After installation is complete, your hard drive should look like this.

Fig. 16: Installation complete.

Congrats: R and RStudio are now on your hard drive.

As a result of the previous steps, there should now be two new folders in folder R on your hard drive. Your hard drive should look like this now:

USB after download of both

Fig. 17: Installation complete.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!

Connect R (statistics program) and RStudio (steering application)

The 'control' of R with RStudio can only work if both programs are connected. How to connect the programs is described in the following section.

The procedure varies depending on whether or not an R version was previously installed on the computer.

Connecting if no other R version is installed on the computer

You can also start here if you are not sure whether another version has already been installed. This is tested in the second step and you can switch to the alternative manual if necessary.

Here we go:

  1. Start RStudio: Go to the RStudio .exe file on the hard drive (path: USB-Stick-> folder 'R' -> folder 'RStudio') and double click on 'RStudio.exe'.

Fig. 18: Start RStudio.

  1. After double-clicking on the .exe file, a window appears in which the R version can be selected. To do this, select 'Choose a specific version of R:' and then click on 'Browse…'.

Fig. 19: Choose a specific version of R.

If this window does not appear and RStudio starts directly instead, a version of R is already installed on the computer. Then please go directly from here to the next chapter 'Establishing a connection if an R version is already installed on the computer'.

  1. In the next window, navigate to the folder in which the R-Start file was installed and continue there to the "bin" folder (path: USB-Stick-> Folder 'R' -> Folder 'R-Portable'-> Folder 'App' -> Folder 'R-Portable' -> Folder 'bin').

Fig. 20 "bin"-folder.

  1. There select the 'i386' folder for the 32bit version of R (alternatively the 'x64' folder for the 64bit version). As a rule, 32bit is sufficient for the less computation-intensive tasks in our courses. Select the folder by clicking on it or open it by double-clicking it, then click 'Select folder'. So here no file is selected, only the folder:

Fig. 21: Choose R-version.

  1. Now the version is displayed in the 'Choose R Installation' window, click 'OK' there. Then it may take a moment for R Studio to start completely. After that the window should look like this: On the left you can see which R version RStudio is connected to. Here in the example is the version 'Eggshell Igloo'.

Fig. 22: R start.

Now you can start working with RStudio and R!

To start an RLab course, the next step is to install these courses.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!

Establish a connection if an R version is already installed on the computer (or if the connection needs to be changed later).

  1. Start RStudio first, as described in the previous chapter 'Connecting if no other R version is installed on the computer'.

Fig. 23: Start RStudio.

  1. RStudio starts, but may not be connected to the correct R version. This will now be checked or adjusted: Navigate to 'Global Options…' via 'Tools'…

Fig. 24: Global options RStudio.

  1. …and in the 'Options' window under 'General' use the 'Change' button to open the Version Selection window:

Fig. 25: Global options: General settings.

  1. Select the desired version there (usually the most current) - either from the list or, if the desired version is not displayed there, via 'Browse…'.

Fig. 26: Browse for most current R version.

  1. Attention: It is important to take a close look to select the correct version. Especially on computers with multiple R versions installed, the entries in the list can be a bit confusing. It helps to check the file path selected in the list carefully.

Fig. 27: Attention - select correct version.

  1. After clicking 'OK', it may take a moment for RStudio to connect to the selected R version. After that the window should look like this: On the left you can see which R version RStudio is connected to. Here in the example is the version 'Eggshell Igloo'. URL R portable

Fig. 28: R start.

Now you can start working with RStudio and R!

To start an RLab course, the next step is to install these courses.

Have you encountered a problem?
The RLab team is always grateful for suggestions and comments to improve this digital script! You can also ask questions about the content! Drop a comment!