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:
- R Instructor, created “to bridge the gap between authoritative (but expensive) reference textbooks and free but often technical and difficult to understand help files“.
- R Console Free. provides the necessary C, C++ and Fortran compilers to build and install R packages.
- There’s always possible to root your device and install a Linux distribution for Android, which will let you install any repository/package, just like in any linux console.
- Running R from your dedicated R server or from an external one (see R-fiddle), using your own browser. I see this option as particularly useful for those who want maximum performance.
- Some additional thoughts on this topic are also stored in these Stack Overflow pages.
- Without needing to root my device, I found GNURoot, an app that “provides a method for you to install and use GNU/Linux distributions and their associated applications/packages alongside Android“.
Finally, my preferred solution came with GNURoot (see this tutorial), 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 app instructions, download and install a linux distribution to run. In my case, I chose the .apk GNURoot Wheezy (a Debian Wheezy distro without Xterms). EDIT: Just be sure of having enough memory for it in your device
3. Once installed, just follow the steps 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:
5. Then, update the sources.list file. We don’t have any graphical text editor (like gedit or kate)… but we have nano!:
Using the volume up + “W/S/A/D” you can move between the lines. Or alternatively, you can install a convenient keyboard with arrow buttons, like Hacker’s Keyboard! (thanks to JTT!)
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 install r-base r-base-dev
6. Now, you only have to run R just like in any bash console:
With this method you only have a prompt, without any graphical interface. ¿How do I make and see plots here?. If R runs from “inside” Android one option is to connect your Linux to an X-server app (thanks, J. Liebig). However, due to memory issues, I couldn’t put in practice this idea and see what happens. Try at your own risk! :)
Fortunately, there’s always possible to print R graphs in various formats, with the inconvenient that you have to browse to the plot’s location in Android -every time you need to check the output.
Here I leave a small script to begin playing with R on Android. Hope you enjoy it!