jackeblagare
jackeblagare

Reputation: 417

Installing R 3.0.2 in Ubuntu 16.04

I'm having trouble trying to install R 3.0.2 in Ubuntu 16.04. I tried adding the repositories of older versions of R but the package for R 3.0.2 cannot be found in apt-get. Has anyone tried installing an older version of R on a newer version of Ubuntu? May I know what the steps are?

I tried also specifying the version in the apt-get install command but it didn't find the right package.

Upvotes: 0

Views: 1380

Answers (2)

Fábio
Fábio

Reputation: 829

I see the best option in your case is to compile R. If you have never done such a thing, follow this little script in terminal:

# install common R dependencies
sudo apt-get install gcc \ 
                g++ \ 
                gfortran \ 
                bzip2 \ 
                libbz2-dev \ 
                xorg-dev \ 
                liblzma-dev \ 
                libreadline-dev \ 
                libpcre++-dev \ 
                libcurl-dev \ 
                libpango1.0-dev


mkdir R_alternatives
cd R_alternatives
mkdir src
mkdir 3.0.2
cd src
wget https://cran.r-project.org/src/base/R-3/R-3.0.2.tar.gz
tar -xvf R-3.0.2.tar.gz
cd R-3.0.2

#In my opinion is better to compile in one folder (avoid uncompress tar.gz source again, if you get any errors)

mkdir BuildDir
cd BuildDir
# this step will take around 2 minutes
./../configure --with-readline=no --with-x=no --prefix=/home/'user'/R_alternatives/3.0.2
# These two will take longer!!
make
make install

# following the prefix in 'configure' your R libraries are going to be installed in /home/'user'/R_alternatives/3.0.2/lib64/R/library/
# Hence, each time you compile a new R version, it will have its own libraries (this avoid R packages versions problems)
# If you wish more than one library version for the same R version, you must create a new folder and then run
export R_LIBS=/'path_to_your_new_folder'

# If you plan to use this R version in RStudio, you have to edit ~/.bash_profile, therefore you must run:
vi ~/.bash_profile
#or, It is up to you!
gedit ~/.bash_profile

#Then you put this line in end of the file

PATH=/home/'user'/R_alternatives/3.0.2/bin:$PATH
export PATH

# OR...

RSTUDIO_WHICH_R=/home/'user'/R_alternatives/3.0.2/bin/R
export RSTUDIO_WHICH_R

#PS: You can also set the R_LIBS here, in the same way!

Upvotes: 1

Maurits Evers
Maurits Evers

Reputation: 50668

First off, see here for a similar & older question on SO.

Pre-compiled binaries of older R releases for various Ubuntu versions (mostly the LTS releases) are available as deb's from the following website:

https://cran.r-project.org/bin/linux/ubuntu/

Unfortunately, there doesn't seem to exist a R 3.0.2 deb package for xenial; only precise still has the R 3.0.2 package. You could try to install the precise package in xenial, but that may come with its own problem set.

Might be best to compile from source following Facottons advice.

Upvotes: 0

Related Questions