How to install latest version of R on Ubuntu 12.04 LTS? [duplicate]

I am not able to download the latest R version on my Dell Vostro 14 3000 Series laptop running on Ubuntu 12.04 LTS.

I typed in the standard commands on Terminal:

sudo apt-get update

sudo apt-get install r-base

sudo apt-get install r-base-dev

But the net result is R 2.14.1 getting installed instead of R 3.2.0 (latest version) or even 3.1.1

I'm a Linux / Ubuntu newb, so please do guide keeping that in mind. Cheers!


Solution 1:

GUI method

  1. In the Ubuntu Software Center, click "Edit > Software sources..."
  2. On the "other software" tab, click "Add..."
  3. Enter the following settings:
    • Type: Binary
    • URI: http://cran.fhcrc.org/bin/linux/ubuntu
    • Distribution: trusty/
    • Components:
    • Comment: R CRAN

This creates a new "software source" that will be checked alongside the regular Ubuntu/Canonical software repositories. After you do this, you need to re-run sudo apt-get update to query the new repository. After that, your system will default to installing R from the CRAN source rather than Canonical, since the CRAN source will always have an equal or greater version number.

Important notes

  • the URI line can have lots of different values, and you should pick one that is geographically close to you from the list of CRAN mirrors. cran.fhcrc.org is in Seattle, USA.
  • the Distribution line should match the "codename" of your Ubuntu version, which you can get by typing lsb_release -cs in a terminal window.

Terminal method

There are good instructions here. Briefly:

codename=$(lsb_release -c -s)
echo "deb http://cran.fhcrc.org/bin/linux/ubuntu $codename/" | sudo tee -a /etc/apt/sources.list > /dev/null
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 r-base-dev

Again, replace cran.fhcrc.org with a geographically appropriate choice from the list of CRAN mirrors.