Sometimes there is not enough memory to do something... the following will add 3GB of swap memory.
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=3072
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1
sudo sh -c 'echo "/var/swap.1 swap swap defaults 0 0 " >> /etc/fstab'
https://community.rstudio.com/t/install-readr-package-on-ec2-instance/6939/13
https://devanswers.co/guide-creating-swap-space-ubuntu-16-04/