Install R and RStudio on Debian 9

This can be real pain… however after a lot of googling I finally figures out how to do it.

Install lastest R version

In your /etc/apt/sources.list add:

deb http://cran.uni-muenster.de/bin/linux/debian stretch-cran35/

(or any other CRAN mirror)

Then import the GPG key of the mirror (in above case it’s gonna be FCAE2A0E115C3D8A):

# most likely have to install 'dirmngr' first:
apt-get install dirmngr

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FCAE2A0E115C3D8A

Refresh and install latest R version:

apt-get update
apt-get install r-base r-recommended

Install latest nightly build of RStudio

Why do you need the nightly build? Because they’ve still not managed
to get rid off the very annoying libssl.so.1.0.0 dependency in their release builds!

Get the latest build for Debian9+ from: https://dailies.rstudio.com/

Then install it with:

dpkg -i rstudio-*.deb