During our DataX course, we recently had an issue where installing the tm package had a dependency on the slam package (that’s Sparse Lightweight Arrays and Matrices for you). This package requires R >3.3.1, which is a shame as I asked students to install 3.2 at the beginning of the course. Don’t despair; keep calm and upgrade R.
First, of all you need to remove your currently installed R. This is easy enough with:
sudo apt-get remove r-base r-base-dev
Note the use of remove instead of purge (the latter deletes all conf files associated with R etc.).
Second, you will need to add the latest R repository to your apt sources files. You need to find the correct “codename” (trusty for Ubuntu 14.04, xenial for 16.04).
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu xenial/" > /etc/apt/sources.list.d/R.list'
Third, you need to get the key for this repository and add it to the apt system. This is a way how to tell the updater that you trust the above repository.
sudo gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9 sudo gpg -a --export E084DAB9 | sudo apt-key add -
Fourth, you know need to let apt-get know you have changed the list of places (repositories) you want it to look at (for updates/new packages).
sudo apt-get update
Fifth, we can now actually install R
sudo apt-get install r-base r-base-dev
Voilà, you should now have the latest version or R at your disposal!