Sunday, February 25, 2018

Installing the latest Version of R in Ubuntu

By executing the below commands we can install R in ubuntu. 

sudo apt-get --purge remove r-base
sudo apt-get --purge remove r-base-dev

This install the default version of R. If we want to install the latest version of R, we can follow as:
Uninstalling the previous version of R


sudo apt-get --purge remove r-base
sudo apt-get --purge remove r-base-dev
sudo apt-get --purge remove r-base-core


After that to install R:

sudo add-apt-repository "deb http://cran.rstudio.com/bin/linux/ubuntu $(lsb_release -sc)/"


Then we will have to execute the below commands:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
sudo add-apt-repository ppa:marutter/rdev
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install r-base

Reinstalling R in Ubuntu

For the case if we want to reinstall R on our ubuntu, we have to uninstall R at first. To do so, we can use the bwlow commands:


sudo apt-get --purge remove r-base
sudo apt-get --purge remove r-base-dev


As r-base package is just a metapackage that also installs r-base-core internally. We will have to remove r-base-core to remove fully.

sudo apt-get --purge remove r-base-core

After removing all the packge we will have to use below command to install the R again:


sudo apt-get install r-base
sudo apt-get install r-base-dev