1. How to Install and Configure R on a Linux Server
08/12/2014
EIM MDM Services
Vikrant Singh Bisht
R/SAS Analytics
vikrant.bisht@tcs.com
2. Table of Content
1. Introduction.................................................................................................................................................. 3
2. Pre requisites................................................................................................................................................ 3
3. Setting up and Installing Linux system level libraries (Also referred to as OS level libraries)................................ 3
4. Installing R.................................................................................................................................................... 4
5. Post Installation Verification .......................................................................................................................... 5
6. Conclusion.................................................................................................................................................... 5
3. 1. Introduction
This Documentdescribes how to install R ona Linuxsystem. The list of pre requisite Linuxlibraries needed has also
been documented.Since R is a freeware, information available online is very scattered and incomplete. This
documentattempts at collating all information obtained by performingmultiple proofof concepts.
2. Pre requisites
Asa pre requisite, the user performingthe install should have the ability to sudointo the server as root. Inother
wordsroot accessis a must to performthe install.
The LinuxOperating System usedfor establishing all proofof conceptswas Red Hat 6.3 (Santiago) ,itis
recommended to usea 64bit Operatingsystem to retain the flexibility ofallowing reverse compatibility in case a 32
bit R install is needed onthe same server. The Linuxrepository usedwas as6-u3_64.
The R sourcefiles were downloaded fromCRAN- http://cran.r-project.org.Thesourcerpm’scanbe downloaded
from trustedLinuxftp sites such as ftp://ftp.remotesensing.org orhttp://www.rpmfind.net.
3. Setting up and Installing Linux system level libraries (Also referred to as OS level
libraries)
The OS level libraries that need tobe installed prior toinstalling R fall undertwocategories. The firstcategory
includes those libraries that canbe installed fromthe local Linuxrepository using the yum commandand the second
one includespackages downloadedfrom trusted internet websites that can be installed usingthe rpmcommand.
The table below describes the order in whichthese libraries need to be installed.
Index Library Name Type of
install
(yum/rpm)
Purpose Criticality
1. fontconfig-devel yum Native text support. HIGH
2. libtiff yum Supportfor.tiff files. HIGH
3. Libtiff-devel yum Supportfor.tiff files. HIGH
4. pango-devel yum Header library support. HIGH
5. cairo yum X11 library support. HIGH
6. texlive-latex yum PDF Support. HIGH
7. libRmath rpm N/A HIGH
8. readline-devel yum GNU readline Support. HIGH
9. libXt-devel yum N/A HIGH
10. firefox yum Standard BrowserSupport. HIGH
11. tcl-devel yum N/A HIGH
12. tk-devel yum N/A HIGH
13. bzip2-devel yum Core RSupport. HIGH
14. pcre-devel yum N/A HIGH
15. libxml2-devel yum XMLsupport. HIGH
16. java-openjdk- yum HIGH
4. devel Standard JAVA support.
17. boost-devel yum Pre requisite forR studio. MEDIUM
18. openssl-devel yum SupportforSSL
connections.
HIGH
19. openmpi-devel yum SupportforMPI
connections.
HIGH
20. gtk2-devel yum GraphicsSupport. MEDIUM
21. *texinfo build from
source
Native charactersetsupport. HIGH
22. libjpeg-turbo rpm Standard JPEGfile Support. HIGH
23. R-core rpm R studiosupport. LOW
24. *gdal rpm Standard pre requisite for R
add onpackage rgdal.
LOW
25. *proj build from
source
Standard pre requisite for R
add onpackage rgdal.
LOW
26. *geos build from
source
Standard pre requisite for R
add onpackage rgeos.
LOW
27. jags rpm Standard pre requisite for R
add onpackage rjags.
LOW
28. jags3-devel rpm Standard pre requisite for R
add onpackage rjags.
LOW
*NOTE –These libraries need to be configuredandbuild usingthe configure andmake commandsrespectively.
However,this may vary dependinguponthe sourcerpm. It is recommended tobuild the rpm’s withdefault settings
so as to ensurethat the OSis able to locate the configurationwithoutany issues.
It is very important to updatethebash_profilelocatedat theroot homeafterevery installwiththelocationof
the installedlibrary(separatedby a colon). Thiswillhelp inresolvinginterdependencybetweenlibrariessince
the bash_profileisthe automaticlookup filefromwhere all installationpathsarefetched.
Thespecialinconsolatafix should beupdatedinthebash_profilesinceit is essentialto ensure pdf support. Once
all installationpathshavebeenupdatedinthe bash_profile,addthe following:-
R_RD4PDF =times:inconsolata
Export R_RD4PDF
4. InstallingR
4.1 Downloading the R sourcetar file – The R sourcetar file canbe downloadedfrom the CRANwebsite
(http://cran.r-project.org/)whichisthestandard website for downloadingR.
4.2 Oncethe sourcehas been downloadedonto the Linuxmachine, the followingsteps can be usedto extract,
configureandinstall R :-
4.2.1 Downloading and extracting the source
Navigate to the folder containingthe tar file. Example cd /usr/local/R
5. Untar the sourceusingthe tar –xvf command(ifthe sourcefile has the extension .gz as well then a
gunzipwill need tobe done prior to this step as well.
4.2.2 Compiling,building and installation.
Navigate to within the created by the above twosteps. Example cd /usr/local/R/R-3.1.2.
Configurethe R softwareby issuingthe configurecommandwiththe accompanyingoptions.If all
the pre requisite libraries marked with HIGHcriticality earlier installed successfully,then the
followingconfigurecommandcan be used:-
./configure --prefix=/usr/local/R/R-3.1.2 --with-cairo=yes--enable-R-shlib--with-tcltk --with-
x=yes--with-libpng=yes--with-jpeglib=yes
This ensures that all the capabilities are installed and available, if it is explicitly required notto
include some functionality,then the correspondingflag canbe unset byreplacing the ye s witha no.
Next, from the same location (/usr/local/R/R-3.1.2),executethemake command.This doesnot
need any parameters andwill runfor approximately 20 minutes building up internal libraries forall
configureparameters.
Next runthe commandmake install –this commandwill dothe Rinstall based on the configure
and build steps earlier.
Next the make install-infocommandcanberun-this is optional but helpfulin summarising the
install.
The final commandto be runis make install-pdf.Thiscommandis usedto setup pdfsupport.
5. PostInstallation Verification
Logoutas an administrator and re login as a normal enduser.
Type R at the commandprompt – IfR is installed exactly perthe steps earlier, no soft link creation is
necessary – in case the user experiences some issues, he/she cannavigate to the lib64/R folder
within the installation directory and key in ./R to ensurethe correct64bit version ofR is launched.
Atthe R prompt type in sessionInfo() toverifysession details.
The capabilities() command canbe typed to verify the features that are enabled. Using the
sequenceof steps in this manual, only profmem andaqua capabilities will be FALSE,sincethese
are not supportedin Linux.
The demo(graphics) commandcanbe used to test the graphic capabilities ofthe install.
6. Conclusion
Using the above steps Rcan be installed in the Linux environment with full capabilities.Almost all the steps were
earlier performed UNIXadministration team, butthis documentintends to make this possible for even a nonUNIX
administrator to install andmaintain R onLinux.