Site icon R-bloggers

Install R in Android, via GNURoot -no root required!

[This article was first published on Tales of R » R, 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.

Playing with my tablet some time ago, I wondered if installing R could be possible. You know, a small android device “to the power of R”…

After searching on Google from time to time, I came across some interesting possibilities:

Finally, my preferred solution came with GNURoot, and here’s how I managed to install the newest CRAN repositories!

1. Install the .apk of GNURoot in your Android device. Don’t forget to donate if you like it! 🙂

2. Following the instructions, download and install a linux distribution to run. In my case, I chose the .apk GNURoot Wheezy (a Debian Wheezy distro without Xterms).

3. Once installed, just follow the instructions to launch the Rootfs (Wheezy) as Fake Root. You will see a bash prompt, from which you can access a complete linux directory tree. This is the same as if you were in a computer (however, if you aren’t root you won’t be able to access the directories via your file browser from Android)

4. Now, we just have to update and upgrade:

apt-get update
apt-get upgrade

5. Then, update the sources.list file. We don’t have any graphic text editor (like gedit or kate)… but we have nano!:

nano /etc/apt/sources.list

Using the volume up + “W/S/A/D” you can move between the lines. Following instructions from CRAN, I added the following line to sources.list:

deb http://<favorite-cran-mirror>/bin/linux/debian wheezy-cran3/

Exit saving changes. But before “update and upgrade” again, don’t forget to add the key for the repository running the following:

apt-key adv --keyserver keys.gnupg.net --recv-key 381BA480

5. Update and upgrade…. voilà!

apt-get update
apt-get upgrade

6. Now, you only have to run R just like in any bash console:

One problem of this method is that you only have a prompt, without any graphical interface. ¿How do I make and see plots here?. Fortunately, there’s a lot of options for printing R graphs in various formats, with the inconvenient that you have to browse to the plot’s location in Android.

Here I leave a small script to begin playing with R on Android. Hope you enjoy it!


To leave a comment for the author, please follow the link and comment on their blog: Tales of R » R.

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.