The R statistical package has separate installers for different operating systems. The major operating systems supported are Linux, Windows and Mac OS (X).
The installation files are available at the the "Comprehensive R Archive Network" (CRAN)("https://cran.r-project.org/"). Under this project, the pre-compiles as well as the source code versions of R packages are kept at many URL locations in different parts of the world. We have to download the R installtion files from any one of them.
A new version of R is released approximately once a year, with "patch releases" occuring on a need basis. In any CRAN location, almost all the past versions are kept. Generally, two successive versions do not differ appreciably in terms of the general statistical and computational algorithms. Thus, most of the commands you will learn in this tutorial will work in both R-3.0.0 and R-4.2.0 versions. Only the special extrnal libraries that will not have backward compatibility beyond a point require updated versions of R.
The general installation procedure consists of the following basic steps: 1. Getting into R home page 2. Select a CRAN site in a country among many options that are listed 3. Downloading some version of R software (for a specific Operating System (OS) ) 4. Installing it in the computer. (This step depends on the operating system (OS)) We will now describe procedure for installing R in windows and linux.
1. Go to the R home page at https://www.r-project.org/
2. In order to go to the CRAN mirror page, select the link CRAN under Download title. This opens the CRAN mirror page. Here, the URL addresses for the download are listed countrywise. 3. Choose a CRAN mirror URL. This leads to the CRAN mirror page. For example, under the country name "Australia", select the URL https://cran.csiro.au 4. Here, unser the title Download and Install R, select the link
Download R for Windows
5. Select the linkInstall R for the first time
This opens a page in which latest R version is kept. For example, select the linkDownload R-4.2.0 for Windows
This downloads an executable file like "R-4.2.0-win.exe". 6. Just run this windows installer. This will install R-4.2.0 smoothly. After installation, an R icon will appear on the desktop. Just click on the icon to open R exection window.Note : There are two versions of the R executable, one for 32 bit machines and the other one for 64 bi machines. By default only the first is installed on 32-bit versions of Windows, and both on 64-bit version of windows OS.
There are two ways of installing R in a Linux operating system. We can either install a pre-compiled version of R from or we can download the source code from CRAN repository and compile it. Both methods are described here.
Method-1 : Installing a pre-compiled version of R from R repositiry To install the pre-compiled version of R for the Ubuntu or the Fedora linux, follow these steps: Step-1 : Update the repository with the following Linux command:Installtion of source code version of R by compiling it in linux requires many pre-existing software in the linux OS. In order to check this, a configuration file has to be run before compilation. This file checks whether the required software (like for example, fortran, C, C++, Python compilers, X11 windows system etc) are already present in the systems with which the R files can be compiled and linked. If any required file is missing, this configure script will report it and we have to install the software before configuring again. The compiler will compile only after proper configuration.
Following are the steps for installation of R in linux systems:
1. Go to the R home page at https://www.r-project.org/
2. In order to go to the CRAN mirror page, select the link CRAN under Download title. This opens the CRAN mirror page. Here, the URL addresses for the download are listed countrywise. 3. Choose a CRAN mirror URL. This leads to the CRAN mirror page. For example, under the country name "Australia", select the URL https://cran.csiro.au 4. Look under the section titled Source Code for all Platforms If we need to install latest release, click on the release name link like "R-4.2.0.tar.gz". A window appears with facility to download and save this file. This file is downloaded and saved into "Downloads" directory of linux in general, unless the automatic default directory setting for downloaded files has been changed. or, If we want to install slightly older version, click on the link "Source code of older versions of R is available here". Click on this, and navigate to stable but new versions like "R-4.1.0.tar.gz". On click, you can download and save this file. At the end of the exercise, we get a file like "R-4.2.0.tar.gz" or "R-4.1.0.tar.gz" which is a tar zipped directory of whole installation. 6. Create an installation directory : Now we need to create a directory where R will be installed. As an example, let /home/user be the R installtion directory decided by us. Do the following: Copy the file "R-4.2.0.tar.gz" in to /home/user directory. From home directory, give the linux commands:
The above command unpacks the tar zip file, and you have new the directory like /home/user/R-4.2.0/ created. All the R install files are here. The configure script is also here. We have to go inside this directory to configure and compile
7. Run configure script:We can install multiple versions of R in the same machine. Sometimes multiple versions are required because of the fact that some external libraries will work only upto certain backward versions. We will be forced to install the older versions for these libraries to work.
In the R installation for linux described above, steps 1 to 8 prepare a compiled version of R with executables. Step 9 actually installs this by copying the R executables to files like "/usr/lib", "/usr/local/lib", "/user/bin" etc.
After installing a new version (eg) R-4.2.0, We can start with another R version file like (eg) "R-4.0.0.tar.gz". We can proceed upto step 8 to compile and create executables. After this, do not proceed with installtion step 9 . If you do so, this will overwrite the previous executables in directories like "/user/bin" etc. Just keep them. In order to run this new version, just navigate in to R installtion directory to find the R executable and run it from there. This executable called "R" is generally found inside "bin" directory inside the installtion directory. This way, we have one new version as default, and many other old installtions that can be run when need arises. When we give the command "R" from inside any directory, the default version should start since its executables are kept at "/usr/bin" or "/user/local/bin" as the case may be. For a detailed and best installtion procedure, visit this installtion and administration page of R-CRAN project.