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.

David
  • 233
  • 1
  • 2
  • 9

4 Answers4

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.

goldilocks
  • 56,430
  • 17
  • 109
  • 217
  • 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 Jan 17 '16 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 Jan 17 '16 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 Jan 17 '16 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 Jan 17 '16 at 16:05
  • ARM is pretty much the standard for [SBCs](https://en.wikipedia.org/wiki/Single-board_computer) because there are lots of cheap low power ARM processors around (they are also used in smartphones). I know Intel has their own SBC but it is > $100. **However**, I may have good news for you since 3.2.x is in Debian *stretch* (the current testing branch) and may be in the Raspbian equivalent. Gimme a few minutes to check. – goldilocks Jan 17 '16 at 16:15
  • 1
    Okay, there is 3.2.2 :/ See the stuff edited in above at the end. – goldilocks Jan 17 '16 at 16:28
  • 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 Dec 06 '16 at 17:27
  • @Luke Generally prerequisites are not things that "may not be needed", they're things that *are needed*, even if you do not understand why. An issue with pulling from the testing repo is that they may depend on other things from testing; e.g., if R has library dependencies that are already installed for the jessie version, and you want to use the stretch version, some of them may (but not necessarily) also need a newer version installed. In this case you'd end probably end with two versions installed, one of which may be superfluous in theory, but that's the nature of the beast. – goldilocks Dec 06 '16 at 17:35
  • If using R in as new a version as possible is a priority for you and you are using a multicore model pi (2 or 3), you might want to look into another distro such as Ubuntu. That's not available for single core models, but Arch is, which will also likely be more recent than the Raspbian default. Raspbian is based on Debian, which has an explicitly conservative policy regarding versioning (i.e., they tend to upgrade later than anyone else). Make sure you do find out for sure what is available for what before you bother, obviously. – goldilocks Dec 06 '16 at 17:39
  • @goldilocks thanks, I realise that dependencies would be required, and perhaps in reality it just noticed lots of other packages that were out-of-date or had new dependencies too, so went ahead and updated them as well. This Pi is a Model B+ (i.e. single core - although not my only Pi) and I now have v3.3.2 so pretty happy with that :) cheers – Luke Dec 06 '16 at 17:41
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.

n1k31t4
  • 181
  • 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 Dec 06 '16 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 Dec 08 '16 at 07: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.

Sanyi Gözös
  • 61
  • 1
  • 1
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

geneorama
  • 153
  • 1
  • 1
  • 5