### Installing R on Linux/Unix Machines from Source Code

Installing R on Linux/Unix Machines from Source Code

Here is a brief description on how to install R on Linux/Unix-based systems by compiling it from source code.

Step 1. Download the platform-independent source code of the latest R release from https://www.r-project.org/. Unpack the folder somewhere. If you have an installation of an old R version that you want to fully replace, remove the old installation. If you want to later install all the CRAN and Bioconductor libraries that you have used on the old version of R, consult with the Steps 2, 3, and 6 of the http://alexonscience.blogspot.co.uk/2015/10/upgrade-r-environmentlibraries-mac-osx.html snippet.

Step 2. Open a terminal window, go to the folder where R source in unpacked, and type

# mkdir /home/alex/prog/R-3.2.2

to generate the folder where R and the add-on libraries are to be installed, then

# ./configure --prefix=/home/alex/prog/R-3.2.2

to configure the make file for the installation. For the commands above and hereafter, replace /home/alex/prog/R-3.2.2 with the appropriate full path of the location you want to install R on and the correct R version number.

An optional addition to the configure command, usually useful while compiling on workstations with missing libraries, would be –with-readline=no.

Step 3. Compile, check and install from the source code using the following commands:

# make
# make check
# make install

Now, you can safely remove the unpacked directory with the R source code generated at Step 1.

Step 4. To make the R and Rscript commands callable system-wide, add the following soft links to a location included in \$PATH. On Linux-based systems, /usr/bin/ would normally work. You can create those links to have version-dependent names, such as R322.

# sudo ln -sf /home/alex/prog/R-3.2.2/bin/R /usr/bin/R
# sudo ln -sf /home/alex/prog/R-3.2.2/bin/Rscript /usr/bin/Rscript

Step 5. From within the R environment (called by typing R on the terminal), install all the necessary CRAN and Bioconductor libraries. As an example:

install.packages("calibrate")

source("http://bioconductor.org/biocLite.R")
biocLite()
biocLite("biomaRt")

If you want to install all the CRAN and Bioconductor libraries that you used on the previous version of R, see the Steps 2, 3, and 6 of the http://alexonscience.blogspot.co.uk/2015/10/upgrade-r-environmentlibraries-mac-osx.html snippet.

External packages can be downloaded and installed via a terminal command (not from within R), such as:

# R CMD INSTALL <path to the package tar.gz file>

Step 6.

Have a cup of tea; you are done!