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 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 --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 dependency in their release builds!

Get the latest build for Debian9+ from:

Then install it with:

dpkg -i rstudio-*.deb