Install the sf package on Ubuntu 20.04

I was unable to install the sf package on a clean Ubuntu 20.04 setup, and the problem is attributed to incompatible software versions. My workaround, instead of installing the package from source, was to install a precompiled binary package, but that depends on configuring a PPA for GDAL.

To add the PPA I run this command from bash

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt update && sudo apt upgrade

The last command updated some packages that sf sources required, which I installed with

sudo apt-get install libgdal-dev gdal-bin libproj15 libproj19 libproj-dev

Then I added a PPA maintained by CRAN, which contains binary R packages

sudo add-apt-repository
sudo apt update && sudo apt install r-cran-sf

And that’s it!