This procedure was tested on Ubuntu 23.04 but should be very similar or identical on other verions.
Note that this will likely not install the latest version of R but the one that is included in the Ubuntu package repository. Installing a newer version can be tricky since the R project doesn't always support all recent releases of major Linux distributions. For most use cases, especially for education, the slightly older version of R will be prefectly fine though.
All commands in this guide need to be run as user root
or with sudo
.