Skip to content

Run R code in Google Colab

Run R online in portable fashion, without installing any program

Use-case:

Run R in any computer or machine online using Google Colab, without the need to install R or R editors such as R Studio.

Video Tutorial for this blog is available here:

Check out these related tutorial in your convenient time:


Method1: using rpy2 package

Step1: Setting up R in python environment of google colab

%load_ext rpy2.ipython

Step2: installing and loading R packages in google colab

Use “%%R“ in beginning of all the blocks you want to use R code in it

%%R
# Install pacman ("package manager") if needed
if (!require("pacman")) install.packages("pacman")

# Load contributed packages with pacman

pacman::p_load(tidyverse,plotly)  

Step3: test the use of R

Method 2:

Add language parameter as below to the end of url of the google colab code:

Use https://colab.research.google.com/#create=true&language=r, or this short URL https://colab.to/r

Related Links

Leave a Reply

Your email address will not be published. Required fields are marked *