Use R in the cloud

A quick guide about how to how to run R via a cloud computing (serverless) option.

Installation guides quickly become outdated. This page last updated 19 August 2024 and describes working installation protocols at that time.

Quick links

Run R on your computer (i.e., local development environment or LDE)

This guide is about running R in the cloud, serverless options. For installing R and R Commander onto your own computer, see Install R and Install R Commander.

Run R “in the Cloud”

If you do not wish to install R, or, if you have a ARM-based Chromebook and, therefore cannot gracefully install R, then there are alternatives; Run R in the Cloud. I’ll list five ways to run R in the cloud — run R on a server, not your own computer — for free.

Note: None of these options can run R Commander, which requires a local (on your computer) installation of R.

If you have a Chromebook, or you want to run R on your tablet (iPad, Kindle, etc.), you can’t install R to any of these devices. However, you can access R via a serverless Cloud solution.

1. Run R code at Online R Compiler using myCompiler‘s online IDE, link at https://www.mycompiler.io/online-r-compiler.

Screenshot myCompiler

Figure 1. Screenshot of myCompiler session.

2. Run code snippets in CoCalc by folks at SageMath and available at https://cocalc.com/ . CoCalc uses Jupyter Notebooks, a wonderful, open-source project which supports interactive computer coding for many languages, including R and Markdown.

While CoLab is my go to, CoCalc is a really good student option — hint: I have my Systems Biology students use this option — includes SageMATH, python, GNU Octave and other software.

Create a free account (you’ll then be able to save your code), or simply click “Run CoCalc Now” and check the box to agree to the terms to begin a session (Fig. 2). Choose to open a new Jupyter notebook, then select R (system wide) from the choice of kernels.

Screenshot CoCalc

Figure 2. Screenshot of Google Colab session.

You can load files from your computer for use in CoCalc sessions. There is also a version of the software you can download to your computer.

3. My favorite option, run R code snippets at Google Colaboratory (Fig. 3). Like CoCalc, Colaboratory uses Jupyter Notebooks. Log into your Google account, then click https://colab.research.google.com/notebook#create=true&language=r , or try the tinyURL https://colab.to/r

Screenshot or R session on Google Colab

Figure 3. Screenshot of Google Colab session.

Colabs is worth the effort — you end up with a system to run R in your browser, it’s free to use, and you can store/retrieve files from your Google Drive. This is my choice for Cloud computing, and it’s the most generic solution. For more information, see post by Ed Adityawarman, How to use R in Google Colab . Colab Jupyter notebooks use Python by default. To run R, either use the link listed above each time you want to create a new R notebook, or add the following code snippet to your new notebook page

# activate R magic - must begin each R code with %%R
%load_ext rpy2.ipython
For all subsequent R code, start the section with
%%R

Note: You can install Jupyter onto your computer via Minicondaconda is an open source package management system but then, you still would have to install R to your computer.

One real advantage of choosing CoLab, there are apps to run Google Colaboratory and Jupyter Notebooks on iPad/iPhone and for Android phones are available at Apple App Store and Google Play, respectively.

4. You can run RStudio at Posit Cloud. Registration and use is free for students. This works OK, but can be slow and it’s hard to work on your own data. It does have the advantage of providing the familiar RStudio interface. Choose the free plan; Instructions to get started are at https://posit.cloud/plans. A screenshot of an RStudio cloud session is shown in Figure 4.

screenshot RStudio Cloud session

Figure 4. Screenshot of RStudio Cloud session.

5. For limited use, i.e., you just need to run a little code to solve an assignment problem, you can run R code snippets in your browser at https://rdrr.io/snippets/ . You’ll see many of my code embedded in this service so that you can run code snippets from my Chaminade University CANVAS pages.

screenshot R session at rdrr.io snippets

Figure 5. Screenshot of rdrr.io/snippets session.