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
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.
- See the R Download page
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
Install - Language Selection (see also the full-size image)
Press OK to continue.
R
Install - License (see also the full-size image)
Press Next > to continue.
R
Install - Install Folder (see also the full-size image)
Accept the defaults. Press Next > to continue.
R
Install - Install Components (see also the full-size image)
Accept the defaults. Press Next > to continue.
R
Install - Startup Options (see also the full-size image)
Accept the defaults. Press Next > to continue.
R
Install - Start Menu (see also the full-size image)
Accept the defaults. Press Next > to continue.
R
Install - Additional Tasks (see also the full-size image)
Accept the defaults. Press Next > to continue. The files will install.
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
- 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 folderC:\Program Files\R\R-3.6.1\
- specific R software version folderC:\Program Files\R\R-3.6.1\bin\
- R executable program main folderC:\Program Files\R\R-3.6.1\bin\x64\
- folder for 64-bit R executable programs, can be added toPATH
on 64-bit Windows systemsC:\Program Files\R\R-3.6.1\bin\i386\
- folder for 32-bit R executable programs, can be added toPATH
on 32-bit Windows systems
- User files:
C:\Users\user\AppData\Roaming\R\
- not sure how these are used
- System files:
Install RStudio
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
Install - Initial Step (see also the full-size image)
Press Next > to continue.
RStudio
Install - Installation Folder (see also the full-size image)
Accept the default to use a generic installation folder. Press Next > to continue.
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
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
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
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
- 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 folderC:\Program Files\RStudio\bin\
- folder for 64-bit R executable programs, can be added toPATH
- 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
- User files:
C:\Users\user\AppData\Local\RStudio-Desktop\desktop.ini
- incidates path toR
software to use with RStudioC:\Users\user\AppData\Roaming\RStudio\
- folder for RStudio user files such as saved projects
- System files:
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.
- See: Package List.
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.
RGui
Install Package (see also the full-size image)
Press OK. Then select the package to install as shown in the following figure.
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:
RGui
Install Package Console Output (see also the full-size image)