Installing R packages on Mint 17.1: cluster, KernSmooth, Matrix, nlme, mgcv

Installing R packages on Windows is easy: you run the install code and it always works. Not so on Linux! Here one sometimes has to install them thru apt-get (or whatever package manager) or install some missing system-level dependencies. Finding what to do can take a lot of time gooling and trial and error. So, in the spirit of contribuing to the internet about how to get stuff to work.

1: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘cluster’ had non-zero exit status
2: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘KernSmooth’ had non-zero exit status
3: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘Matrix’ had non-zero exit status
4: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘nlme’ had non-zero exit status
5: In install.packages(update[instlib == l, "Package"], l, contriburl = contriburl,  :
  installation of package ‘mgcv’ had non-zero exit status

These all installed for me after installing:

sudo apt-get install r-base-dev
sudo apt-get install gfortran