Installing R 4.0.2 on Ubuntu 20.04

I'm trying to install R version 4.0.2 on Ubuntu 20.04 via: sudo apt-get install r-base=4.0.2 but I get

Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Version '4.0.2' for 'r-base' was not found

although it does exist.

I then tried following the instructions here which detail the instructions for installing the latest version of R:

# update indices
apt update -qq
# install two helper packages we need
apt install --no-install-recommends software-properties-common dirmngr
# import the signing key (by Michael Rutter) for these repo
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

Then:

apt install --no-install-recommends r-base

For the last step, I tried r-base=4.0.2 instead since I don't want the latest version but I again get the same problem

EDIT: Based on Henning's answer, I ran apt policy r-base, which gave me:

r-base:
  Installed: (none)
  Candidate: 4.1.0-1.2004.0
  Version table:
     4.1.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.5-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.4-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.3-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.2-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.1-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     4.0.0-1.2004.0 500
        500 https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ Packages
     3.6.3-2 500
        500 http://us.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu focal/universe i386 Packages

So I then tried sudo apt-get install r-base=4.0.2-1.2004.0 which gave me:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 r-base : Depends: r-recommended (= 4.0.2-1.2004.0) but 4.1.0-1.2004.0 is to be installed
E: Unable to correct problems, you have held broken packages.

I tried installing r-recommended but I still got the same issue


The Ubuntu repositories for Focal offer R 3.6.3. Just because another version of a software exists, that doesn't automatically mean that somebody packaged that version for Ubuntu (or Debian, or Fedora, or...) and offers those packages in their repository ;)

As for the repository offered by r-project.org, you may want to check what exact versions are available there. You can do that with apt policy r-base (after you added the repository to your list of package sources, of course). At the end of the output, there should be something along the lines of

 Version table:
 *** 3.6.3-2 500
        500 http://de.archive.ubuntu.com/ubuntu focal/universe amd64 Packages
        500 http://de.archive.ubuntu.com/ubuntu focal/universe i386 Packages
        100 /var/lib/dpkg/status

In those version designations, you not only find the version of the "base software" (in this case, the version of R), but also the version of the Debian package built from that software, and often the version of the Ubuntu packages built from the Debian packages.

In this example, the only available version of r-base is 3.6.3-2. That basically means "R version 3.6.3, and version 2 of the Debian packages built from that". An example with information about the version of the Ubuntu packages would be apache2-2.4.41-4ubuntu3.1 (version 2.4.41 of the Apache HTTP server, version 4 of the Debian package built from that, and version 3.1 of the Ubuntu package built based on the Debian package).

So, your version designation to use in apt install isn't just the version of R, but the full version of the package you want to install (provided that package is in any of the repositories your system "knows" about, of course).