Install R

You can find step 1-6 in R official website here here

  1. update indices
sudo apt update -qq
  1. install two helper packages we need
sudo apt install --no-install-recommends software-properties-common dirmngr
  1. add the signing key (by Michael Rutter) for these repos . To verify key, run gpg –show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
  1. add the R 4.0 repo from CRAN – adjust ‘focal’ to ‘groovy’ or ‘bionic’ as needed sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

Replace $(lsb_release -cs) with jammy as follows:

sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/"
  1. Then install r-base
sudo apt install --no-install-recommends r-base
  1. If you encounter a conflict with package dependencies such as libicu70, which is not available in Ubuntu 23.10, (you can obtain the download link from the Ubuntu package here)
wget http://nz.archive.ubuntu.com/ubuntu/pool/main/i/icu/libicu70_70.1-2_amd64.deb

sudo dpkg -i libicu70_70.1-2_amd64.deb
  1. For the installation of libtiff use the following command. (the download link is available from the Ubuntu packages here).
wget http://security.ubuntu.com/ubuntu/pool/main/t/tiff/libtiff5_4.3.0-6ubuntu0.8_amd64.deb

sudo dpkg -i libtiff5_4.3.0-6ubuntu0.8_amd64.deb
  1. Try again installing r-base:
sudo apt install --no-install-recommends r-base

Installing Rstudio

  1. Download the Rstudio version for Ubuntu 22/Debian 12 from Posit Website
  2. Open a terminal in the directory where you downloaded it and install using the provided command. Remember to adjust the Rstudio version in the command to match the one you downloaded.
sudo dpkg -i rstudio-2023.12.1-402-amd64.deb
  1. If there are package dependencies, try to resolve them using the provided command, then attempt the installation (step 2) again.
sudo apt --fix-broken install