15

I've recently acquired a machine with Ubuntu 18.04 on it. I installed R simply with:

sudo apt-get install r-base

And when I call $ R in console, it starts up with:

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...

I'd like to get R 3.6 installed, primarily because I need BiocManager and a bunch of latest versions of other R packages obtained through BiocManager. I've followed the steps here, so now my /etc/apt/sources.list/ looks like (just the bottom bit that's relevant):

deb http://security.ubuntu.com/ubuntu bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://security.ubuntu.com/ubuntu bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://security.ubuntu.com/ubuntu bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse
deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/
# deb-src https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/
# deb-src https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

And ran sudo apt-get install r-base again.

But when I run $ R from the console again, I still see:

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"
Copyright (C) 2018 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
...

Is there something I'm missing? I'm new to setting up R and Linux in general, so I sense that there's a bunch of literature I'm missing about what's available via apt-get, R versioning for Ubuntu, and so on. Any links to useful man pages would also be very helpful.

Edit: Following the comments:

Ran:

sudo apt update
sudo apt-get install r-base

To no new effect; callnig R from console still brings up R v3.4.4.

apt-cache policy r-base shows:

r-base:
  Installed: 3.4.4-1ubuntu1
  Candidate: 3.4.4-1ubuntu1
  Version table:
 *** 3.4.4-1ubuntu1 500
        500 http://au.archive.ubuntu.com/ubuntu bionic/universe amd64 Packages
        500 http://au.archive.ubuntu.com/ubuntu bionic/universe i386 Packages
        100 /var/lib/dpkg/status

Which I assume means R v3.6 isn't even being installed at all?

AndreyIto
  • 349
  • 1
  • 3
  • 8
  • Did you run `sudo apt update` before trying to install the latest version? What does `apt-cache policy r-base` show? – ajgringo619 Sep 04 '19 at 02:15
  • Also, you need to remove the `deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/` line; you've already added the correct (bionic) line. – ajgringo619 Sep 04 '19 at 02:35
  • I had exactly the same problem and I found this tutorial: https://linuxize.com/post/how-to-install-r-on-ubuntu-18-04/ It solved my problem, hope it helps you! – Weld Lucas Cunha Feb 29 '20 at 13:16

4 Answers4

7

According to https://cran.r-project.org/bin/linux/ubuntu/README.html you should add (considering you are using 18.04, bionic)

deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/

to your

/etc/apt/sources.list

after that

sudo apt update

and

sudo apt install r-base
MarujoRe
  • 171
  • 2
7

Unfortunately i can not comment on the answer of AndreyIto.

For me it has to be xenial-cran35 instead of disco-cran35

So:

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt update
sudo apt install r-base

For Details and other Ubuntu Versions see cran.r-project.org:

CodePrinz
  • 173
  • 1
  • 3
5

I successfully installed R 3.6.1 on Ubuntu 18.04.3 following this:

sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
sudo apt update
sudo apt install r-base
Kevdog777
  • 3,194
  • 18
  • 43
  • 64
AndreyIto
  • 349
  • 1
  • 3
  • 8
1

try

echo deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/ | sudo tee /etc/apt/sources.list

sudo apt update

sudo apt install r-base

R --version
Jakub Jindra
  • 1,392
  • 1
  • 12
  • 25
Punpun
  • 11
  • 1
  • 1
    Welcome to the site, and thank you for your contribution. Your answer could benefit from some explanation on why these steps help solve the problem, as the possible audience is not only the OP but other people with possibly less experience in system administration. – AdminBee Apr 16 '20 at 09:11