Raspberry Pi 4

Installing R on Raspberry Pi 4 with Ubuntu 20.10 (64-bit)

The Raspberry Pi 4 is a great incremental improvement of the RPi platform. It handles Ubuntu 20.10 64-bit decently.

I mainly use R for my data-science practice, and I wanted to try R on this RPi. As of November 29, 2020, there are no pre-built packages I can use to install R. At a minimum, no r-base-core package is available for the arm64 platform at the R package repository. You have to compile R yourself.

Here’s a way to do it. AndrĂ©s Castro Socolich provided most of this, and I edited a couple of steps. Open a terminal window (Ctrl-Alt-T) and run the below lines, one at a time. Be advised: I have an RPi 4 with 8 GB RAM, and it used almost half the RAM at one point. Also, the first make command will take a long time.

  1. sudo apt update
  2. sudo apt upgrade
  3. sudo apt-get install -y gfortran libreadline6-dev libx11-dev libxt-dev libpng-dev libjpeg-dev libcairo2-dev xvfb libzstd-dev texinfo texlive texlive-fonts-extra screen wget zlib1g-dev libbz2-dev liblzma-dev libpcre2-dev libcurl4-openssl-dev openjdk-11-jdk
  4. cd /usr/local/src
  5. sudo wget https://cran.rstudio.com/src/base/R-4/R-4.0.3.tar.gz
  6. sudo su
  7. tar zxvf R-4.0.3.tar.gz
  8. cd R-4.0.3
  9. ./configure --enable-R-shlib
  10. make
  11. make install
  12. cd ..
  13. rm -rf R-4.0.3*
  14. exit
  15. cd

You’re done! To run R, type R (yes, capital R) at the command prompt.

17 thoughts on “Installing R on Raspberry Pi 4 with Ubuntu 20.10 (64-bit)”

  1. Have you noticed that you have several repeated packages? it doesn’t make any harm but still unnecesary.
    e.g. libbz2-dev, liblzma-dev, libpcre2-dev, libcurl4-openssl-dev

    1. Not yet. I last tried about 15 days ago. I think there was a QT-related dev package that was needed, and I had problems getting it compiled or something. I do not specifically remember.

  2. Hi Aren

    I followed your instructions successfully…however when I hit R in the command line I still get R version 3.5.2. Any clue why?

    1. Is there any chance you already installed R from Ubuntu’s package manager? If so, you may have already had 3.5.2 installed.

      I just checked, and it looks like it’s been updated to 4.0.2 in package manager, so it may have been a while. If you update packages, and the R version you get becomes 4.0.2, then that would support my theory, that you’re using the package manager’s R instead of what you compiled.

      1. Hi Aren

        Thx for your quick reply.

        Yeah I initally installed R via sudo apt-get install r-base r-base-core r-base-dev

        Than I tried to update to 4.0.2 but still launced 3.5.2 via the command prompt. So I thought it wasnt installed correctly and tried your way.

        FYI Im really new to Linux, I thought a new R install would overwrite the old one. But I understand thats not the case? So I need to remove 3.5.2?

        1. I am not a Linux expert, but I could understand if software installed through a package manager would conflict with software you build. I think that self-built software will be fairly vanilla, and package-manager-installed software could have optimizations that go beyond a vanilla build.

          I recommend you remove the packages that you installed through apt-get and retry the R 4.0.3 build. Removal guidance is at https://askubuntu.com/a/187891/206842.

  3. this is great.
    I was about to give up and rewrite all my background r scripts in py.
    thanks, great job!
    installed successfully on Ubuntu Server 20.04.2 LTS on RPi4B 8GB Ram. during install, average CPU load 25%, Ram load 12%, using ethernet.
    confirmed correct R version running.

  4. Hello Mr Arem!
    I recently got into RPi and I’m trying to get some Rscripts run on it, but I’m having a hard time installing some R packages, i. e. “polite” package.

    Can you explain how can I install packages?

    Thank you in advanced.

  5. I’m sure that there is something I’ve missed in this process. When I get to step #8 and give the command “make” I get the following error message:

    make: *** No targets specified and no makefile found. Stop.

    Is there something besides just “make” that I need to enter?

  6. Congratulations Aren…

    I followed your steps in Ubuntu 20.04.3 LTS (focal) and could install data.table and tidyverse packages successfully.


  7. Thanks Aren (and Andres)!

    Minor question: If I have followed your path, what is the preferable way to upgrade to R.4.1.1? Since, at least in my case, r-base-core is not yet available for Debian Buster above 3.5. Repeat your steps above with the upgraded R version? Or is there a faster way?

    1. I am unsure. I would guess that you follow the instructions all over again, as you suspected. If it works like Windows, then you’ll potentially have two, concurrent versions of R on your device, so you’d potentially need to specify which version to use when you run a script.

  8. Thanks a lot! That solved it for me (after trying various backport repositories until realizing that these do not contain packages for the ARM architecture).

Leave a Reply to Aren Cambre Cancel reply

Your email address will not be published. Required fields are marked *