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

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! (NOTE: It should work “out of the box” but, as problems might appear, some experience with Linux is always advisable).

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:

apt-get update
apt-get upgrade

5. Then, update the sources.list file. We don’t have any graphical 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. 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 --recv-key 381BA480

5. Update and upgrade…. voilà!

apt-get update
apt-get upgrade
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!


42 pensamientos en “Install R in Android, via GNURoot -no root required!

      • Android X-server..? Hadn’t thought of that! [post update]
        Following your idea I tried to install it and see if it works “out of the box” or it needs root features.
        So I went to Google Play to get “XServer XSDL” but my memory was full; it wasn’t possible for me to try it.
        My tablet isn’t a high end one: R works fine but it seems that I cannot do much more without rooting it..

  1. Have you considered installing Hacker’s keyboard from the Google Play, since it introduces arrow keys, which makes editing and moving around in command line a bit easier than the standard keyboard?

    • yes! I knew about this great app, and if I continue to mess around with R in my tablet, I will definitely have to install it! Thanks (will do a small edit in the post according to this idea)

  2. Very, very cool. Thanks for that post. I’ll bookmark it an will read it, at some point, more thoroughly.

    I see a future where during a scientific conference all x64 enabled Android devices will be connected by ad-hoc WiFi, running R instances on their free cores, contributing their computing power to solve particularly nasty equations in global datasets, gridcell by gridcell…

    Well, probably not. But it’s still cool to be able to run R on your mobile. ^_^

    • Hehe…yes, and maybe someday will be useful for solving small problems as you go…anyway, it’s cool and fun!
      Maybe R in a tablet will be better for users who would sacrifice performance for some portability.. not to mention the possibility of accessing an R server from your browser.. it seems that we will have plenty of options in the future!

  3. Cool, will have to give this a go. Maybe you can install rstudio server and then access the graphical interface through the browser? Then you’ll have easy access to plots etc.

  4. Nice, works for me on a cheap tablet! Managed to install ggplot2, dplyr and devtools as well (this latter required libcurl4-gnutls-dev), though it took some time… 🙂 A suggestion: maybe you should extend Step 5 with `apt-get install r-base`.

    • My tablet is also a low-end one, and it works fine. However I currently have memory issues, so I could only install a few packages. -including ggplot2 and gdata to import excel files-.
      Thanks, I will update the post with your suggestion!

    • How do you get dplyr and devtools installed? When I try to install it via install.packages, I get the error message “package … is not available (for R version 2.15.1)”.
      Is there a way to upgrade R from within this Debian distribution to R 3.x?

      • I have currently little disk space to reinstall and test this, but I think that you may have the version of R (2.15) that comes native 6with Wheezy.
        The point of this tutorial is to add an updated CRAN repository to the sources.list file, to get the last version of R.
        As this Debian distro doesn’t have X (window/graphical system), one solution is to use Nano or Pico, both text editors that work from the console.
        Once sources.list is ready, the process is similar to any Linux installation of R, it should update and upgrade itself using the update/upgrade commands.
        If sources.list updating doesn’t work (for whatever reason), you can always download a previous version of the dplyr package manually and try to install from the R console: install.packages(path_to_file, repos = NULL, type=”source”)
        And the old sources of dplyr that probably work with R 2.15:

  5. Hi, it sounds great!
    However I got stuck at point 3. I was able to launch wheezy as fake root, but then it says
    bash: dircolors: command not found
    when I write ‘apt-get update’ and press enter, it again says ‘command not found’.
    I have probably missed something obvious, but I have no experience with Linux. Will be greatful for any advice!

    • Hi,
      I don’t really know what can be happening here, but I would do the following to try to solve it:
      1. Lack of memory in your phone -I’d suggest to check this.
      2. Some other unknown problem during installation -I would uninstall both the Wheezy rootfs and the GNURoot app, and reinstall it again.
      Then I would repeat the steps 1, 2, 3 and 4
      3. If the same issue happens again, maybe the problem is in the PATH environment. Without a proper PATH, Wheezy cannot locate where are the commands that you want to run.
      I would try to re-set it with the command:
      export PATH=/usr/bin:/bin
      (not sure if this PATH setting is the most suitable).
      Hope this helps!

      • Hi,
        Many thanks for your help!
        The line of code export PATH=/usr/bin:/bin really helped.
        I was able to proceed through steps 4 and 5s (there are two), but when I run apt-get upgrade I receive the following error:
        Can not write log, openpty() failed (/dev/pts not mounted?)
        dpkg: warning: ‘ldconfig’ not found in PATH or not executable
        dpkg: warning: ‘start-stop-daemon’ not found in PATH or not executable
        dpkg: error: 2 expected programs not found in PATH or not executable
        Note: root’s PATH should usually contain /usr/local/sbin, /usr/sbin and /sbin
        E: Sub-process /usr/bin/dpkg returned an error code (2)

        I tried to ignore the error and to install R. The instalation seemed to proceed, but at the end I get the same error and R does not run:
        root@localhost:/# R
        bash: R: command not found

        It seems to me there is some problem with the path, but I have no idea how to solve it, I can’t even understand what is bash…
        (my tablet is samsung note 8 with 4 giga of free memory)

        Will be very greatful for any advice!

  6. Hi again,
    I forgot to say that my device has Android Lollipop. Just un case anybody asks, GNUroot and GNU Wheezy instalación worked right out of the box. And installing R was pretty easy. Thanks again.

  7. Hi! Thanks for the usefull manual!
    But if the version 3.2.2 is also available? I’ve tried to get it by replacing wheezy with jessie in the sources.list but get some errors always 😦

  8. I have finally managed to install GNURoot! It is wonderful to have Debian programs inside my tablet without having to root it… By the way, is it safe to login as a root user? I mean, even if the tablet is not rooted, could I (accidentally) delete any important file of the Android operating system because of having logged in Debian as root@localhost?

    • It seems like a great question I’d ask to Corbin Champion itself! you could easily delete any file from the Debian distro (hence the extreme caution when logging in as root in GNU/Linux).
      But I don’t really know if you can escalate permissions inside the Android filesystem and delete files. I’d just be careful about this. Good luck!

  9. After opening the terminal and starting up R, I like to call a script form within R that is saved in the working directory. How do I do this? What I find with e.g. Rscript seems to work from e.g. bash command line, but not from within R.

  10. So, GNURoot doesn’t work on Android 5.1+, the only version that works is GNURoot Debian. I’ve been able to get GNURoot Debian up and running however it’s missing nano. I’ve tried (sudo) apt-get update & install nano however it keeps hitting an error. (Here’s the surround lines to)

    Get:1 jessie/main nano armhf 2.2.6-3 [353 kB]
    Fetched 353 kB in 0s (918 kB/s)
    debconf: delaying package configuration, since apt-utils is not installed
    E: Granting access to slave /dev/pts/1 based on master fd 32 failed! – grantpt (13: Permission denied)
    dpkg: error processing archive /var/cache/apt/archives/nano_2.2.6-3_armhf.deb (–unpack):
    cannot get security labeling handle: No such file or directory
    Errors were encountered while processing:

    Do you have any ideas or anything?

    • I cannot reproduce your installation process since my newest Android version is 4.4.4. I also found that GNURoot was taking too much sdcard memory so I had to temporarily uninstall it.
      However, i do have a few ideas to try -to at least get nano-:

      Is ‘pico’ installed instead of ‘nano’?

      Do you have enough memory in your device?

      The first error was that apt-utils was not there. Could you install it? then you can type ‘dpkg-reconfigure -au‘ to try to reconfigure nano.

      By the way, I installed R in a Raspberry Pi (ARM processor, with a Debian-like distro), and I found that the latest R versions were still not available for ARM…

  11. Hi,

    I’m facing a small issue here. I’ve completed all the steps but it says me that bash R command not found. I have also tried to export PATH=/usr/bin:/bin as well as export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin, but with no luck.
    Any ideas? Thank you

  12. Hi,
    Do you, perchance, know where would I find the root location of R, through Android file system (Solid Explorer with root access)? I accidentally saved a session there, and I can’t find it anywhere.

    • I’d suggest, from the GNURoot terminal, opening R and typing:
      > getwd()
      to see the default path where R will store files and sessions (your session may be there). Then you can navigate to the file using Solid Explorer in Android. HTH


Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de

Estás comentando usando tu cuenta de Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s