The Ubuntu repository does not have the latest version of R, so it installed the old version.
If you want to install the latest version of R, you need to update your apt source.list file.
Here are the steps:
1. Since you are installing R on Ubuntu 20, edit the file /etc/apt/sources.list and add the following line. For other versions of Ubuntu, check the list here.
deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/
2. Add the key to your system using the following command. Without adding the key, it will not fetch the latest version from CRAN.
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
3. If steps 1 and 2 did not fail, you are all set to install the latest version. To install the complete R system, use the following commands:
sudo apt-get update
sudo apt-get install r-base
Your computer will now have the latest version of R.