---
title: Running R and RStudio from an Android mobile phone or tablet
date: 2016-10-20
published: 2016-10-20
tags: ['technology', 'r', 'rstudio', 'android']
stale: true
description: "Compiling and running RStudio Server on a rooted Android device inside a Debian Linux container via Linux Deploy."
---

[R](http://www.r-project.org) is a popular statistical computing environment, and [RStudio](https://www.rstudio.com/products/rstudio/) is a commonly used editor for it, featuring syntax highlighting and code completion. There is even a [server version](https://www.rstudio.com/products/rstudio/download-server/) that runs in the browser. In this post, I'll go through the process of compiling RStudio Server locally onto an Android device.

## Preface

This process involves tinkering with your device's software and can lead to data loss or rendering the device unusable. Ensure your data is safely backed up. It is a good idea to only try this on a spare device.

## Getting started

You'll need a rooted Android device. I used a Moto X (2013) developer edition flashed with a pre-rooted nightly image of CyanogenMod 13. Have at least 4 GB of storage available, keep the device plugged in, and disable power-saving features during installation and compilation.

## Installing Debian

[Debian](https://www.debian.org/) is a Linux distribution with [ARM ports](https://www.debian.org/ports/arm/) suitable for Android devices. I used an Android app named [Linux Deploy](https://github.com/meefik/linuxdeploy) alongside a compatible [BusyBox](https://play.google.com/store/apps/details?id=ru.meefik.busybox) installation.

Once installed, set up your Linux container. Allocate a minimum of 4 GB. Since we're installing RStudio Server, a graphical environment is not needed — uncheck it. Keep the SSH server enabled. My settings can be found [here](/images/r-rstudio-on-android/linux-deploy-settings.png).

Once configured, let Linux Deploy set everything up. This takes 30 minutes to an hour. Completion is indicated by `<< install`. When started from a stopped state, the status should look like this:

![](/images/r-rstudio-on-android/linux-deploy-start.png)

## Housekeeping

Access your Debian install via SSH from another computer on the network or from an Android SSH client such as [JuiceSSH](https://play.google.com/store/apps/details?id=com.sonelli.juicessh). Linux Deploy displays the device's network address when open.

```
ssh 192.168.1.X
```

Log in with your account details (default password `changeme`) and change it immediately:

```
passwd
```

Update the system:

```
sudo apt-get update
sudo apt-get dist-upgrade
```

Install useful tools:

```
sudo apt-get install screen openjdk-7-jdk git
```

## Compiling RStudio Server

I've uploaded a modified shell script to [ARM-rstudio-server](https://github.com/thomasteoh/ARM-rstudio-server), based on work by [dashaub](https://github.com/dashaub/ARM-RStudio) and [jrowen](https://github.com/jrowen/ARM-rstudio-server).

```
screen
wget https://raw.githubusercontent.com/thomasteoh/ARM-rstudio-server/master/build_rstudio.sh
sudo bash build_rstudio.sh
```

This takes over 10 hours. Leave it overnight. Once complete:

```
sudo rstudio-server start
```

## Accessing RStudio

Access RStudio Server from any browser on the device at `127.0.0.1:8787`, or from another computer on the same network at port `8787`. You will be presented with a username and password prompt — use your Debian account credentials.

Once logged in, RStudio runs in the browser much like the desktop version, with the console, environment, and file panes intact.

![](/images/r-rstudio-on-android/rstudio-server-running.png)

From there, install your packages and access your code. Bookmark the address and pin a shortcut to your home screen for easy access.
