I fixed this error on Ubuntu by carefully following the instructions for installing R. This included:
deb http://cran.utstat.utoronto.ca/bin/linux/ubuntu trusty/
to my /etc/apt/sources.list file sudo apt-get update
sudo apt-get install r-base-dev
For step 1 you can chose any CRAN download mirror in place of my University of Toronto one if you would like.