(you can modify the cran mirror)
R_VERSION='3.6.1'
wget https://cran.univ-paris1.fr/src/base/R-3/R-${R_VERSION}.tar.gz
Untar and cd to the dir
sudo tar -xzvf R-${R_VERSION}.tar.gz
cd R-${R_VERSION}
Configure (possible to remove params but these are the one I usually set)
sudo ./configure \
--prefix=/opt/R/${R_VERSION} \
--enable-memory-profiling \
--enable-R-shlib \
--with-blas \
--with-cairo=yes \
--with-lapack \
--with-libpng=yes \
--with-x
Make
sudo make; sudo make install
Verify it's installed
make check
Check it's installed
/opt/R/${R_VERSION}/bin/R --version
Add to your path
export PATH=$PATH:/opt/R/${R_VERSION}/bin
More info: