Keeping R up to date on Ubuntu linux

R is included as part of the standard Ubuntu distribution, and can be installed with a command like

sudo apt-get install r-base

Obviously the software included as part of the standard distribution usually lags a little behind the latest version, and this is usually quite acceptable for most users most of the time. However, R is evolving quite quickly at the moment, and for various reasons I have decided to skip Ubuntu 12.10 (quantal) and stick with Ubuntu 12.4 (precise) for the time being. Since R 2.14 is included with Ubuntu 12.4, and I’d rather use R 2.15, I’d like to run with the latest R builds on my Ubuntu system.

Fortunately this is very easy, as there is a maintained repository for Ubuntu builds of R on CRAN. Full instructions are provided on CRAN, but here is the quick summary. First you need to know your nearest CRAN mirror – there is a list of mirrors on CRAN. I generally use the Bristol mirror, and so I will use it in the following.

sudo su
echo "deb precise/" >> /etc/apt/sources.list
apt-key adv --keyserver --recv-keys E084DAB9
apt-get update
apt-get upgrade

That’s it. You are updated to the latest version of R, and your system will check for updates in the usual way. There are just two things you may need to edit in line 2 above. The first is the address of the CRAN mirror (here “”). The second is the name of the Ubuntu distro you are running (here “precise”).

About these ads

Tags: , , , , , ,

7 Responses to “Keeping R up to date on Ubuntu linux”

  1. Mehmet Suzen Says:

    Brilliant. One addition though. If you are behind firewall like myself, one needs to use port 80 for the keyserver i.e.

    apt-key adv –keyserver hkp:// –recv-keys E084DAB9

  2. The R-Podcast Episode 11: Reproducible Analysis Part 1 (Introduction) » The R-Podcast Says:

    [...] Guide to installing latest version of R on Ubuntu: [...]

  3. swaroop Says:


  4. Steve Laurie Says:

    Cut and paste and functioned pefectly – thanks – luckily I am using pangolin still as I didn’t check that bit. :-)

  5. Clive Darwell Says:

    Thank you so much. I guess I will never understand why so many people are incapable of explaining these things as simply as you have done here.

  6. Sophie Says:


  7. nononana Says:

    Thanks, near two years old and still works!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 155 other followers

%d bloggers like this: