how can I update R to version 4 on ubuntu

I'm using Ubuntu 20.04.3 LTS. I'm using R version 3.6.3. Some packages is not in there. Therefore I need R version 4. or higher than 4. I tried those things: sudo -H gedit /etc/apt/sources.list then I added this line: deb http://cran.rstudio.com/bin/linux/ubuntu focal/ then sudo apt-get update and sudo apt-get install r-base but it doesnt work. Somebody help me?


The R guide to install on Ubuntu has already covered this, I tried the command and it seems to give R 4.0. Result of apt-cache policy.

$ apt-cache policy r-base
r-base:
  Installed: (none)
  Candidate: 4.1.1-1.1804.0
  Version table:
     4.1.1-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.1.0-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.5-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.4-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.4-1build1 500
        500 https://mirror.gi.co.id/ubuntu hirsute/universe amd64 Packages
     4.0.3-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.2-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.1-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     4.0.0-1.1804.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/ Packages
     3.4.4-1ubuntu1 500
        500 https://mirror.gi.co.id/ubuntu bionic/universe amd64 Packages

Instruction below taken from R installation guide.

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
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
sudo apt update
sudo apt install --no-install-recommends r-base