RStudio

RStudio Server is the premier integrated development environment for R that allows to move computation close to the data and scale compute and RAM centrally.

This is a pre-configured image with R and open source editions of RStudio Server and Shiny Server. All dependencies are solved for you to just go and use this droplet with already configured tidyverse, data.table, and other widely used packages so that in three clicks and no more than five minutes you’ll have your server running and ready to fit models, share Shiny apps and much more.

Aside of fully solved dependencies, this image features a LaTeX installation and OpenBLAS to boost some numerical operations. This image is prepared, to a wide extent, to install, say, plumber and other packages as a wide variety of dependencies (i.e. libsodium-dev) are already solved.

Software Included

Package Version License
R 4.2.1 GPL-3
RStudio Server 2021.09.2+382 AGPL-3
Shiny Server 1.5.16.958 AGPL-3
openJDK 11.0.10 GPL-2
OpenBLAS 0.3.8 BSD-3
TeX Live (Basic) 2021 GPL-2
R Development - devtools 2.4.2 GPL-3
R Development - usethis 2.0.1 MIT
R Datasets - data.table 1.14.0 MPL 2.0
R Datasets - tidyverse 1.3.1 GPL-3
R Databases - arrow 6.0.1 Apache 2.0
R Databases - RMariaDB 1.1.1 GPL-2
R Databases - RPostgres 1.3.2 GPL-3
R Documentation - bookdown 0.22 GPL-3
R Documentation - rmarkdown 2.9 GPL-3
R Documentation - xaringan 0.22 MIT
R Documentation - Rdpack 2.1.2 GPL-3
R Parallelization - doParallel 1.0.16 GPL-2
R Parallelization - future 1.21.0 LGPL-3
R Statistics - brms 2.17.0 GPL-2
R Statistics - cmdstanr 0.5.1 BSD-3
R Statistics - tidymodels 0.1.3 GPL-3
R Visualization - DT 0.18 GPL-3
R Visualization - highcharter 0.8.2 MIT + Highcharts License
R Visualization - shinydashboard 0.7.1 GPL-3
R Visualization - shinyjs 2.0.1 MIT
Fail2ban 0.11.1 GPL-2
libsodium 1.0.18 ISC
NGINX 1.18.0 NGINX License

Creating an App using the Control Panel

Click the Deploy to DigitalOcean button to create a Droplet based on this 1-Click App. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.

Deploy to DO

Creating an App using the API

In addition to creating a Droplet from the RStudio 1-Click App using the control panel, you can also use the DigitalOcean API. As an example, to create a 4GB RStudio Droplet in the SFO2 region, you can use the following curl command. You need to either save your API access token) to an environment variable or substitute it in the command below.

curl -X POST -H 'Content-Type: application/json' \
         -H 'Authorization: Bearer '$TOKEN'' -d \
        '{"name":"choose_a_name","region":"sfo2","size":"s-2vcpu-4gb","image": "rstudio-20-04"}' \
        "https://api.digitalocean.com/v2/droplets"

Getting Started After Deploying RStudio

Access to the shell from Digital Ocean Control Panel (i.e. see the details here) or by using ssh. Then type adduser rstudio (or any other user) and hit ’enter’. You are free to set “rstudio” as password, but please set a safe password.

Now you are ready to use RStudio! Go to 203.0.113.0:8787 (look for the real IP in your control panel) and access with the user rstudio and the password previously defined. But there are optional steps for enhanced security.

It’s also possible to use analogsea to automate both droplet and user creation. This is useful if you plan to create many users.

Creating a system administrator account

It is highly recommended that you create an administrator account separate from root.

Let’s create the user paul from the console (browser or SSH):

adduser paul
usermod -aG sudo paul

For the full reference please check this DigitalOcean tutorial.

Adding more users

Let’s create three users that will only be able to install R packages to their personal directory (and of course to use R, RStudio and Shiny):

adduser john 
adduser george 
adduser ringo

Now delete the rstudio user:

deluser rstudio

Using RStudio Server with encryption

Run this command from the terminal (useful if your network has blocked ports):

ssh -f root@203.0.113.0 -L 8787:203.0.113.0:8787 -N

And then, from the browser go to localhost:8787.

Custom domain and enabled https

Let’s say that you want people from your organization access RStudio Server from rstudio.ourcompany.us instead of 203.0.113.0:8787.

DigitalOcean tutorials already covered the additional steps to do that by using Nginx or Apache. This image already includes Nginx to simplify things a bit.

Security notes

  • The SSH access for the rstudio user is disabled without an SSH key.
  • The current version features fail2ban to provide some security.
  • After 5 incorrect login attempts, the IP where the fail comes shall be banned from HTTP/SSH logins.
  • If you are accidentally banned, you shall need to visit digitalocean.com and access your droplet from the Dashboard’s console and follow and unban your IP.