在Android上安装R

时间:2016-05-01 15:30:15

标签: android r rstudio

我正在尝试将其安装在Android操作系统上(我有一台三星Galaxy平板电脑)。我想安装R和RStudio。

我已经上网试图了解这一点,但大部分文章都很陈旧(可追溯到2013年)并且对我没有多大意义。

我的个人笔记本电脑(带有Windows操作系统)上安装了R和R工作室,发现这些设置非常简单,但在平板电脑上找出如何做到这一点时遇到了一些麻烦。

如果有人最近这样做并成功了,请告诉我。

3 个答案:

答案 0 :(得分:9)

  1. 从Google Play安装GNURoot
  2. 从Google Play安装Gnuroot Wheezy。见http://www.linux-magazine.com/ Online/Blogs/Productivity-Sauce/GNURoot-Linux-on-Android-No-Root-Required 获得更多帮助。
  3. 更新软件包存储库(两次!):

    apt-get update    apt-get update

  4. 阻止系统Perl的更新:

    apt-mark hold perl-base

  5. 安装R:

    apt-get install r-base

  6. 从Debian存储库安装所有可用的cran包:

    apt-get install r-cran *

  7. 从命令行启动R:

    [R

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

答案 1 :(得分:2)

Rstudio服务器无法在非root设备上运行,该设备安装在termux的ubuntu中。相关链接:rstudio in android - rootednon-root rstudio discussion

我在无根设备中找到了两种解决方法。在浏览器或VNC Viewer上工作。

1。浏览器方法

(已在使用Android 7.1的Yoga Book和具有Android 8的Huawei手机中进行了测试-尺寸为ggplot 1.66 Gb)

  • 安装termux(google play)(由于termux没有运行jupyter-IRkernel,因此我必须安装ubuntu)
  • 在termux(MFDGamingNeo-Oli)中安装ubuntu。
  • 在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 
  • R内部:
    # Package necessary for jupyter
    install.packages("IRkernel")
    IRkernel::installspec()
    q()
  • 在ubuntu中,运行jupyter实验室
    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

  • 您需要在电池设置中禁用termux的自动休眠状态。

注意:在termux应用程序(谷歌播放)中可以安装R,请参见Conor link;重要的setupclang-gfort-8步骤可以在安装makegcc-8并在(过时的)Conor协议的输出中使用新的程序包名称之后完成。如果需要GUI,则会出现问题。一个选项是Rcmdr软件包,但是由于termux还没有tcl-tk,如您在capabilities()中在R中看到的那样,我结束了在termux中安装ubuntu

2。 VNC方法

  • 与在浏览器方法中一样,安装termux和ubuntu
  • 在ubuntu中安装aterm
  • 在ubuntu中安装R后(请参见上文),安装R Commander GUI软件包:
    #in R:
    install.packages("Rcmdr")
  • 在ubuntu中安装vnc4server
  • 在Android中安装VNC Viewer(Google Play)。
  • 在ubuntu中启动VNC服务器:
    tigervncserver -xstartup aterm
  • 在VNC Viewer中,连接到127.0.0.1:5901显示屏所对应的:1(以白色显示aterm),在R中打开aterm ,然后是library(Rcmdr)

  • 绘图后,请参见ggplot示例,我不得不(盲目地)编写dev.off(),因为没有其他方法可以返回到脚本窗口。

    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

注意:我也在ubuntu中安装了X11,但似乎并没有改善Rcmdr的GUI体验。在带有android的瑜伽书中,@ Ajay答案无效。

答案 2 :(得分:0)

不完全是R Studio,但仍然很酷……请遵循Installing R on Android via Termux中的Conor Anderson's blog指南。

步骤1:从F-Droid(或Google Play商店)安装Termux

Install from F-Droid

步骤2:添加其无意义的软件包存储库

一次输入以下命令:

pkg install curl gnupg
mkdir -p "$PREFIX/etc/apt/sources.list.d/"
echo "deb https://its-pointless.github.io/files/ termux extras" > "$PREFIX/etc/apt/sources.list.d/pointless.list"
curl "https://its-pointless.github.io/pointless.gpg" | apt-key add

步骤3:安装所需的.deb软件包

安装以下软件包。最好单独安装每个软件包以监视警告,我认为此时某些软件包可能已被弃用。

pkg install r-base \
            make \
            clang \
            gcc-7 \
            libgfortran \
            openssl-dev \
            libcurl-dev \
            libicu-dev \
            libxml2-dev

第4步:配置编译器

setupclang-gfort-8

第5步:输入大写字母R启动R

R

步骤6:使用Nvim-R或您喜欢的其他任何东西进一步自定义

R on Android