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.
sudo apt update
sudo apt upgrade
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
sudo wget https://cran.rstudio.com/src/base/R-4/R-4.0.3.tar.gz
tar zxvf R-4.0.3.tar.gz
rm -rf R-4.0.3*
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)”
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
Oops, thank you! That is fixed.
have you been able to compile rstudio on the raspberry?
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.
Thank you Aren your article truly helped me out
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?
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.
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?
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.
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.
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.
I don’t think package installation would be different than with normal R installs.
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?
I followed your steps in Ubuntu 20.04.3 LTS (focal) and could install data.table and tidyverse packages successfully.
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?
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.
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).