Site icon R-bloggers

A new image on DigitalOcean to start using RStudio Server without waiting more than 2 minutes

[This article was first published on Pachá, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

At the end of the post there is a promotional link for free DigitalOcean credits.

Motivation

I initially made a close-access image for DigitalOcean because I wanted to spend my lectures and workshops giving useful examples and not solving software installation issues. Now you can use my RStudio image which available on DigitalOcean Marketplace, it costs $0 except for the cost of running the server, and it’s also scalable.

For novice users, installing R can be hard, that’s why I wrote a guide with videos in english here and I translated it to spanish here. The best solution I found was to provide my students a read to use droplet and then during the term me or the TAs can help them installing the software.

Description

This is a pre-configured image with open source editions of RStudio Server 1.1. and Shiny Server 1.5. All dependencies are solved for you to just go and use the next compiled R packages (the setup already includes R 3.5, TeX Live 2018 and OpenBLAS):

  • Databases: RMariaDB, RPostgreSQL
  • Development: devtools, testthat
  • Documentation: bookdown, pkgdown, rmarkdown, roxygen2
  • Parallelization: doParallel
  • Package managemente: pacman
  • Manipulate data: dplyr, janitor, lubridate, purrr, tidyr
  • Plots: ggplot2
  • Read/write data: data.table, haven, jsonlite, readr
  • Reproducibility: crul, packrat, vcr
  • Web applications: shiny

Software included

Package Version License
R 3.5.3 GPL 3
Rstudio Server 1.1.463 GPL 3
Shiny Server 1.5.9.923 GPL 3
OpenBLAS 0.2.20 BSD 3
TeX Live 2018 GPL 2

Results

If you start with a fresh droplet with Ubuntu Server, you have to add CRAN sources to apt, then install the Tidyverse and follow a few steps to solve dependencies and compile R packages.

I completed all of those steps for you, and I documented them here. For example, RPostgreSQL (amazing package!) requires to install libpq-dev which can be installed y using apt-get, all of that and more is already solved.

If you decide to build your own RStudio Server instance, it can take up to 45 minutes considering compilation time. This image gives you the same result in around 2 minutes.

Getting started after deploy

Creating an administrator account

With your just created droplet, open a terminal on your local and login as root:

ssh root@server_ip_address

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

adduser paul
usermod -aG sudo paul

Now the user “paul” will be able to update the system and install software.

For the full reference please check this tutorial.

Adding more users

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

adduser john 
adduser george 
adduser ringo

Using RStudio Server

From any modern browser such as Firefox, type server_ip_address:8787 on the address bar and then enter with any of the users you created before.

Please notice that the droplet already includes different R packages and full LaTeX installation. The next packages are ready to use and you don’t need to re-install them:

  • Databases: RMariaDB and RPostgreSQL
  • Data visualization: ggplot2 and shiny
  • Data wrangling: data.table, dplyr, haven, janitor, jsonlite, lubridate, purrr, readr and tidyr
  • Development: crul, devtools, pacman, packrat and testthat
  • Documentation: bookdown, pkgdown, rmarkdown, roxygen2
  • Parallelization: doParallel

API Creation

In addition to creating a Droplet from the RStudio 1-Click App via the control panel, you can also use the DigitalOcean API.

You can list all 1-Click Apps using the API. As an example, to create a 4GB RStudio Droplet in the SFO2 region, you can use the following curl command. You’ll need to either save your API access token to an environment variable or substitute it into 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":"simplystatistics-rstudio-18-04"}' \
    "https://api.digitalocean.com/v2/droplets"

Get free DigitalOcean credits

Please help me covering the hosting costs of Open Trade Statistics. If you register with this link, you’ll get free credits to try DigitalOcean and I also get credits for my trade project:

My DigitalOcean Referral Link
https://m.do.co/c/6119f0430dad

To leave a comment for the author, please follow the link and comment on their blog: Pachá.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.