10

I have a Raspi that runs Debian Jessie (downloaded from the official Raspberry Download Website (Version 2015-11-21)). For one of my projects I want to use the software r and some of the very useful packages (data.table and ggplot2 if you want to know). However, these packages require the latest r-version (currently 3.2.3 according to CRAN, at least for windows). The official Debian Package Site lists 3.1.1 as the latest version.

If I run sudo apt-get update, and then sudo apt-get install r-base, followed by sudo R I see that I have version 3.1.1 installed (thus, install.packages("data.table") in R returns that it does not exist for this older version).

Now my question is: How can I install the latest version of R (3.2.3), or alternatively how can I install the two packages?

First Try I tried to follow the official description on the CRAN-site (the link doesn't work properly, you need to click through: Download R for Linux -> Debian and then scroll down to "Supported Branches" and "Jessie", where it gives advice to Jessie users. What I did was sudo nano /etc/apt/sources.list and added the line deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/, and then tried to install it again (after removing it with sudo apt-get remove r-base) sudo-apt-get install r-base. But I got the following error:

Error Message

What am I missing/doing wrong? Thank you very much for any ideas/help/advice.

4 Answers 4

9

What I did was sudo nano /etc/apt/sources.list and added the line deb http://cran.rstudio.com/bin/linux/debian jessie-cran3/

Beware that binary packages from there, such as the R interpreter itself, will only work on specific architectures, presumably at least x86 and x86_64.

But you would need one compiled for ARMv6. If you are using a Pi 2 you could also use ARMv7, which is more commonplace, but likely still not available in the repository.

This is why adding that repo will not allow you to upgrade the R version -- you would not and cannot have the proper dependencies available for an x86(-64) binary package, so it cannot offer you the higher version.

There may be pure R packages from there that you can use but obviously if they depend on a higher version of the interpreter then you will need to find that somewhere first.


There does appear to be an R 3.2.2 in the Raspbian stretch (testing) repo. I have a B running stretch and have not had any problems. To install this, you will have to edit /etc/apt/sources.list; it probably now contains:

deb http://mirrordirector.raspbian.org/raspbian/ jessie main contrib non-free rpi

Add stretch to the end of that list. You should now be able to apply the logic explained here, although that was written when "jessie" was testing and "wheezy" was stable.

10
  • On CRAN it reads: "There are i386 and amd64 binaries for jessie, wheezy, squeeze. Since R 3.1.0, R is fully functional on arm and armel binaries for jessie and wheezy are provided here as well."
    – David
    Commented Jan 17, 2016 at 14:44
  • Yes, debian uses i386 and amd64 where I have used x86 and x86-64 but they refer to the same thing. The first is the normative Intel 32-bit architecture on PCs; the second is the now more widely used AMD/Intel 64-bit architecture. Neither of them is compatible with the ARMv6/7 processors used by Raspberry Pis. A problem is that the Debian arm binaries will be ARMv7.
    – goldilocks
    Commented Jan 17, 2016 at 14:48
  • ...Whereas Raspbian is really an ARMv6 operating system regardless of which pi you use it on. So if you are on a Pi 2 and you can get ahold of that arm package, you could try it but there are no guarantees. If you are on a different model, you could try the armel package, but again, it may or may not work. The installer (apt) will probably refuse to do this for you, which makes it awkward.
    – goldilocks
    Commented Jan 17, 2016 at 14:50
  • That's a very good (though potentially devastating(?)) answer. Thanks for it! There is no way around that, right (except trying to recompile the packages/programs from source). Are there other microcomputers (Arduino, Raspi, etc) who have a compatible architecture?
    – David
    Commented Jan 17, 2016 at 16:05
  • 1
    Okay, there is 3.2.2 :/ See the stuff edited in above at the end.
    – goldilocks
    Commented Jan 17, 2016 at 16:28
8

[Leaving an answer as I can't yet write comments]

I followed the instructions from @goldilocks (accepted answer) on a brand new Raspberry Pi 3 (September 2016) running Raspbian Jessie, and everything worked as expected.

I had previously installed the version of R available in the Raspbian repo, which was 3.1.1. - too old for many packages! I simply opened /etc/apt/source.list, added an extra line:

deb http://archive.raspbian.org/raspbian/ stretch main

Then

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

Now when I enter R in a terminal window, I get 3.3.1. During the installation, I saw that the new installation replaced the old 3.1.1.

2
  • This does work (thanks, I now have R v3.3.2) but it installs/updates a whole load of other packages as well that may not be needed
    – Luke
    Commented Dec 6, 2016 at 17:26
  • 1
    Glad it worked for you! apt-get should only install required packages to install the three r- packages I listed above (even then, not all system dependencies are guaranteed to be included, based on my experience). If there are packages you don't really need, it may be a result of the development package r-base-dev. You can find out which R-packages are loaded into a session by default and then uninstall them or prevent them from being loaded in future sessions.
    – n1k31t4
    Commented Dec 8, 2016 at 7:58
6

Update from Raspbian GNU/Linux 8 (jessie):

The line

deb http://archive.raspbian.org/raspbian/ stretch main

does not work (at least not from my RPi3)

Replacing it, however, with

deb http://mirrordirector.raspbian.org/raspbian/ stretch main

worked.

0
2

The most direct and up to date instructions are now on CRAN
http://cran.rstudio.com/bin/linux/debian/

This page details which line to add to /etc/apt/sources.list. Find your os with cat /etc/os-release

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.