Installing R through the source building in Linux

   There is a way to install R through the source code. This method is helpful if you have some restrictions on internet access in your network. In this case, first, we need to download source or package then, install them one by one. If this is not your case, please refer to my previous post about R installation. This post is about how to install the R and R packages through the source code. I have done this tutorial in CentOS Linux 7.3.

R installation through the source

First, we need to downloading R source. The latest R source code can be downloaded from the CRAN page. Check the version of your copy and download it with below command.

# wget http://lib.stat.cmu.edu/R/CRAN/src/base/R-3/R-3.4.1.tar.gz
We extract a tar.gz file.

# tar xzvf R-1.4.1.tgz

Change directory to newly extracted R-1.4.1 directory

# cd R-1.4.1

Next, we start 'configure' command.

# ./configure

Then, 'make' command

# make

It takes time to compile sources. After that, we run 'make check' command.

# make check

Then, 'make install' command.

# make install

After successfully compiling and installing, we can run R.

# R
R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
....
>


We have installed R.

Install R packages from the source file

Here also, we first download a package file then install it in R. Let's install 'dateTime' package from the source file.

After googling "dateTime cran r", you can easily go to the CRAN page.

Downloading the package with a wget command.

# wget https://cran.r-project.org/src/contrib/datetime_0.1.2.tar.gz
   In R, we can install package from source with below command. Make sure that you are in the same directory in R, where "timeDate_3012.100.tar.gz" file is located. Otherwise, the full path should be provided with the package name.

> install.packages("timeDate_3012.100.tar.gz", repos=NULL,type="source")

   There are some packages with multiple dependencies. To install them, all dependency packages should be installed before the target package.


No comments:

Post a Comment