Tilastotieteellistä ohjelmointia R-kielellä
R on Android
I have been trying to get R to work on an Android-based device without a need to root the device. I finally found a way to do it!
The solution is based on a Linux installation, GNURoot, that does not require rooting, and the Debian distribution, Gnuroot wheezy, that is meant to be used with GNURoot. Both are available from Google Play, formely Android Market. The installation process goes as follows:
1. Install GNURoot from Google Play 2. Install Gnuroot Wheezy from Google Play. See http://www.linux-magazine.com/ Online/Blogs/Productivity-Sauce/GNURoot-Linux-on-Android-No-Root-Required for more help. 3. Update the package repositories (twice!): apt-get update apt-get update 4. Block updates to system Perl: apt-mark hold perl-base 5. Install R: apt-get install r-base 6. Install all available cran packages from the Debian repositories: apt-get install r-cran* 7. Start R from the command line: R
Unfortunately installing Debian package build-essential runs into problems (a form of a dependency hell, that is), and installing new R packages that would require compiling C or Fortran code is not currently possible. Otherwise the installation seems to work rather nicely.
Another major restriction at this point is that it is not easy to install a graphical user interface to the Gnuroot Wheezy, and therefore you can’t, e.g., see the generated images straight up.
Furthermore, the technique described above installs R version 2.15.1. It supports more binary Debian packages of the R packages than the more current R version. However, if you need a newer R version, you could follow the instructions at CRAN to setup the correct R Debian repository for a newer R version.
This solution has been tested on mobile phone Samsung Galaxy S4 Plus (GT-I9506) running Android version 4.2.2.
EDIT (2014-02-10): See the comment by Corbin Champion below. R 2.5.1 can now be installed in GNUroot Wheezy with the following three commands:
apt-get update apt-get install r-base apt-get install r-cran*
It works like a charm now!
EDIT (2014-02-10): Hint regarding working directories on Android: The external SD Card can be used for analyses, if you first set up the working directory as
setwd("/mnt/extSdCard/"). Similarly, the built-in memory area is located at setwd(”/sdcard/”). Setting the working directory on either sdcard to a suitable directory allows you to generate plots directly to files using functions such as
jpeg(). These require the suitable drivers, and you can check your current R builds capabilities with the function
capabilities(). Plotting does not work, if the applicable file formats are listed as FALSE under printed capabilities list.
Note that this information is provided with best of intentions, but for all purposes, you use it at your own risk.