Skip to content

R / Install R

R is available in two main distributions:

  • R Studio - R integrated development environment that depends on core R, with Free and commercial versions
  • R - core R language

RStudio depends on R being installed first and can only work with compatible versions of R. The following describes how to install R and RStudio:


Install Ro

Windows Install R on Windows

The following instructions describe how to install R on Windows. This documentation was prepared with R version 3.6.1 and other versions may have different installation steps.

Follow the link to download R for Windows. Then run the installer (e.g., R-3.6.1.exe). Run the installer as administrator (right click on executable and Run as administrator.

r-install1-language

R Install - Language Selection (see also the full-size image)

Press OK to continue.

r-install2-license

R Install - License (see also the full-size image)

Press Next > to continue.

r-install3-folder

R Install - Install Folder (see also the full-size image)

Accept the defaults. Press Next > to continue.

r-install4-components

R Install - Install Components (see also the full-size image)

Accept the defaults. Press Next > to continue.

r-install5-options

R Install - Startup Options (see also the full-size image)

Accept the defaults. Press Next > to continue.

r-install6-menu

R Install - Start Menu (see also the full-size image)

Accept the defaults. Press Next > to continue.

r-install7-tasks

R Install - Additional Tasks (see also the full-size image)

Accept the defaults. Press Next > to continue. The files will install.

r-install8-finish

R Install - Finish Install (see also the full-size image)

Press Finish to exit the intaller.

The software can then be run from the Start / R menu.

R and PATH

The R installer does not modify the PATH environment variable. Therefore, to run R on the command line it is necessary to specify the full path to the R software. Running R from the Start menu runs a user interface that knows where the R command line program is installed, and RStudio has a setting for the path to the R program. The PATH can be manually updated to include the path to the R program and will need to be updated if a new version of R is installed.

R Software File Locations

The location of R files is as follows:

  • Windows Windows
    • System files:
      • Note - the following folder structure allows multiple versions of R to be installed at the same time
      • C:\Program Files\R\ - general software installation folder
      • C:\Program Files\R\R-3.6.1\ - specific R software version folder
      • C:\Program Files\R\R-3.6.1\bin\ - R executable program main folder
      • C:\Program Files\R\R-3.6.1\bin\x64\ - folder for 64-bit R executable programs, can be added to PATH on 64-bit Windows systems
      • C:\Program Files\R\R-3.6.1\bin\i386\ - folder for 32-bit R executable programs, can be added to PATH on 32-bit Windows systems
    • User files:
      • C:\Users\user\AppData\Roaming\R\ - not sure how these are used

Install RStudio

Windows Install RStudio on Windows

The following instructions describe how to install R Studio on Windows. This documentation was prepared with R Studio version 1.2.5001 and other versions may have different installation steps.

  • See the RStudio Download page
    • RStudio will be compatible with a version of R so install a compatible version of R if necessary

Select the free RStudio Desktop download for Windows. A non-free version with more functionality can be installed later if necessary.

rstudio-install1

RStudio Install - Initial Step (see also the full-size image)

Press Next > to continue.

rstudio-install2-folder

RStudio Install - Installation Folder (see also the full-size image)

Accept the default to use a generic installation folder. Press Next > to continue.

rstudio-install3-menu

RStudio Install - Start Menu (see also the full-size image)

Accept the default to use a generic Start menu folder. Press Install to continue.

rstudio-install4-finish

RStudio Install - Finish (see also the full-size image)

Close the installer by pressing Finish.

Run RStudio from the Start / RStudio menu. The following prompt will be shown to indicate which version of R is used for RStudio. In the following a specific version of R is selected.

rstudio-install5-select-r

RStudio Install - Select R Version (see also the full-size image)

After selecting an R version to use, press OK. Note that because R does not update the PATH, the RStudio location for R is saved as a full path and will break if a different version of R is installed and the old version is uninstalled. The path to R is stored in the following file (may vary between versions):

  • C:\Windows\Users\user\AppData\Roaming\RStudio\desktop.ini
    • Set in Tools / Global Options / General
    • For example: RBinDir=C:/Program Files/R/R-3.6.1/bin/64

The following may be shown if the graphics renderer changes.

rstudio-install6-renderer

RStudio Install - Restart because Renderer Changed (see also the full-size image)

RStudio and PATH

The RStudio installer does not modify the PATH environment variable. RStudio is typically run from the Start menu rather than the command line. The R software can be run from the command line.

RStudio Software File Locations

The location of RStudio files is as follows:

  • Windows Windows
    • System files:
      • Note - the following default folder structure does not allow multiple versions of R to be installed at the same time, although a version could be used to specify a folder during installation, for example C:\Program Files\RStudio-N.N.N
      • C:\Program Files\RStudio\ - general software installation folder
      • C:\Program Files\RStudio\bin\ - folder for 64-bit R executable programs, can be added to PATH
    • User files:
      • C:\Users\user\AppData\Local\RStudio-Desktop\desktop.ini - incidates path to R software to use with RStudio
      • C:\Users\user\AppData\Roaming\RStudio\ - folder for RStudio user files such as saved projects

Install R Package

The core R software functionality is extended by installing packages. The process is similar to the following.

First determine which package is needed, based on researching functionality or using code that requires a package by using the library() statement.

Next use the RGui and select the Packages / Install package(s)... menu item.

Select a CRAN mirror similar to the following, typically a location that is geographically nearby.

package-select-mirror

RGui Install Package (see also the full-size image)

Press OK. Then select the package to install as shown in the following figure.

package-select-package

RGui Install Package (see also the full-size image)

Press OK to install the package. Messages will be displayed in the R Console similar to the following:

package-console

RGui Install Package Console Output (see also the full-size image)