Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing R on Android

Tags:

android

r

rstudio

I am trying to install it on an Android operating system (I have a Samsung Galaxy tablet). I would like to install both R and RStudio.

I've been online to try and find out about this but most of the articles are quite old (going back to 2013) and don't make much sense to me.

I have both R and R studio installed on my personal laptop (with a windows OS) and found these both very straightforward to set up, but having some trouble figuring out how to do this on a tablet.

If anyone has done it recently and been successful please let me know.

like image 350
JassiL Avatar asked May 01 '16 15:05

JassiL


People also ask

Can we install RStudio in Mobile?

Currently we don't have any native support for the RStudio IDE or our server products on mobile devices.

Can I run R on my phone?

Running R and Emacs on my mobile phone Recently I have been running R from my Android phone. There are some apps on the Google Play Store that seem to let you emulate R, or connect to a remote version. Instead of doing that, I have been running R directly off my phone using the terminal.

Can we install R in tablet?

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.

How do I download R app?

Go to the CRAN website. Click on "Download R for Windows". Click on "install R for the first time" link to download the R executable (.exe) file. Run the R executable file to start installation, and allow the app to make changes to your device.


2 Answers

  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

source http://www.r-ohjelmointi.org/?p=1434

like image 79
Ajay Ohri Avatar answered Oct 13 '22 03:10

Ajay Ohri


Rstudio-server didn't work in a non-rooted device, installed in ubuntu in termux. Related links: rstudio in android - rooted, non-root rstudio discussion.

I found two workarounds in a non-rooted device. Working on browser or VNC Viewer.

1. The browser (jupyter) approach

(tested in yoga book with Android 7.1 and Huawei phone with Android 8 - size with ggplot 1.66 Gb)

  • install termux (google play) (As termux didn't run jupyter-IRkernel, I had to install ubuntu)
  • install ubuntu in termux (MFDGaming or Neo-Oli).
  • run this in ubuntu:
    apt update && apt upgrade     apt-get install apt-transport-https software-properties-common      # add R repository     add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/'     apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9     apt update && apt upgrade          apt install nodejs     apt install npm # absence of this causes non-editable cells in jupyter     apt install gfortran     apt install liblapack-dev     apt install libopenblas-dev          # install R     apt install r-base-dev # or r-base or r-base-core          # install python package manager     apt-get install python3-pip      # install jupyter     pip3 install jupyterlab      # open R     R  
  • Inside R:
    # Package necessary for jupyter     install.packages("IRkernel")     IRkernel::installspec()     q() 
  • In ubuntu, run the jupyter lab
    jupyter lab --allow-root     # as you will see you have to paste something like this in your internet browser     http://127.0.0.1:8889/?token=1a0f9b3d472d155bb4d46df119b937646d6192f569c9d635  

enter image description here

  • You would need to disable the automatic hibernation of termux in battery settings.

Note: In termux app (google play) is possible to install R, see Conor link; the important setupclang-gfort-8 step can be accomplished after installing make and gcc-8 and using the new package names in the output of the (outdated) Conor protocol. The problem appears if you want GUI. An option is the Rcmdr package, but as termux has not tcl-tk, as you can see inside R using capabilities(), I ended installing ubuntu in termux

2. The VNC approach

  • As in the browser approach install termux and ubuntu
  • In ubuntu install aterm
  • After installing R in ubuntu (see above), install R Commander GUI package:
    #in R:     install.packages("Rcmdr") 
  • In ubuntu install vnc4server
  • In Android install VNC Viewer (google play).
  • Launch the VNC server in ubuntu:
    tigervncserver -xstartup aterm 
  • In VNC Viewer connect to 127.0.0.1:5901 which corresponds to the :1 display (showing the aterm in white), open R in aterm, then library(Rcmdr).

  • After ploting, see ggplot example, I had to write (blindly) dev.off() because there is no other way to return to the script window.

    require(ggplot2)     ggplot(diamonds) + geom_point(aes(x=carat, y=price, color=cut)) + geom_smooth(aes(x=carat, y=price, color=cut)) 

enter image description here

Notes:I also installed X11 in ubuntu, but didn't seem to improve the GUI experience of Rcmdr. In a yoga book with android the @Ajay answer didn't work.

like image 22
Ferroao Avatar answered Oct 13 '22 03:10

Ferroao