termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

Package Request: R (r-base)

Open tomtom opened this issue 8 years ago • 152 comments

Several users of GnuRoot Debian reported that R works on arm. Currently there is no other way to run R on Android.

tomtom avatar May 04 '16 12:05 tomtom

this would be great!

dm319 avatar Nov 27 '16 11:11 dm319

I find one way to install R. (1) install Fedora see https://nmilosev.svbtle.com/fedora-on-nonrooted-android-phones-2016-update (2) install R yum install R *(3) install KDE yum|dnf install @kde-desktop

muyang avatar Dec 02 '16 20:12 muyang

Umm https://github.com/its-pointless/gcc_termux I actually have an experimental build of R in termux.

its-pointless avatar Feb 18 '17 10:02 its-pointless

@its-pointless thanks for sharing this! Could you describe the installation process a bit more? I tried extractions the files and then modifying the executive files permissions, but I get an error that R can't load libiconv.so.2. Should I be installing it differently?

namdnguyen avatar May 08 '17 14:05 namdnguyen

@namdnguyen follow the instructions in @its-pointless's readme instead, or look at the detailed steps isaacullah provided in this thread.

With this, you can install it as a normal package with packages install r-cran and get updates.

Grimler91 avatar May 08 '17 15:05 Grimler91

@Grimler91 Thank you for the quick reply! I was able to install r-cran with isaacullah's instructions. However, I am still having some trouble getting R to run. I still get the same message, which I'll include below.

CANNOT LINK EXECUTABLE: could not load library "libiconv.so.2" needed by "/data/data/com.termux/files/usr/lib/R/bin/exec/R"; caused by library "libiconv.so.2" not found

I've tried uninstalling and reinstalling iconv to see if that would help, but it doesn't. Any ideas on what I could try next? Am I skipping a necessary step from the README without realizing it?

namdnguyen avatar May 08 '17 21:05 namdnguyen

I will fix it later today ... to compile R needs a more functioning libiconv to compile than is in libandroid-support Thought i made sure it was functioning.

its-pointless avatar May 08 '17 21:05 its-pointless

wait if its asking for that lib that means the executable is the old version

its-pointless avatar May 08 '17 21:05 its-pointless

no wait its arm version that is the problem my mistake

its-pointless avatar May 08 '17 21:05 its-pointless

https://github.com/its-pointless/gcc_termux/blob/master/libiconv.so.2.6.0 is what you want

its-pointless avatar May 08 '17 22:05 its-pointless

Thank you. I copied that to $PREFIX/lib and renamed it to libiconv.so.2 and that message went away, but then it gave a similar message and said that mempcpy was missing.

namdnguyen avatar May 09 '17 06:05 namdnguyen

Oh im about deal with that. Its due to differences between devices since you kind of have to build this on device.

A work around is to find a lib with that has that symbol On your device do nm -A -D /system/lib/lib*.so | grep mempcpy A lib with T memcpy is what you want then LD_PRELOAD=/system/lib/libTHELIB.so R

its-pointless avatar May 09 '17 09:05 its-pointless

Also if you haven't set TMP variable it will complain about not being able to create R_TempDir ...

its-pointless avatar May 09 '17 09:05 its-pointless

Oh ok, no rush. I really appreciate how incredibly responsive you've been. I will wait.

I did try out the workaround you mentioned. I wasn't able to find any libs with mempcpy, but there were a lot with memcpy without the "p".

namdnguyen avatar May 09 '17 14:05 namdnguyen

@its-pointless just to confirm, R is working for me now after the latest update. Thank you so much for your contributions! I now have R and ledger on my phone.

namdnguyen avatar May 10 '17 00:05 namdnguyen

hi, @its-pointless, thanks for this. being able to run R on termux is fantastic. after adding the link to the sources.list, running and update and then

packages install r-cran

the installation was really easy. unfortunately, when i try to launch R, i get this error message:

CANNOT LINK EXECUTABLE: library "libicuuc.so.59" not found page record for 0x7f81152050 was not found (block_size=64)

any ideas?

thanks again. very useful work. with termux, it's getting to the point where i won't be bound to my laptop anymore. if i could only get R to work... :)

wickx avatar May 19 '17 07:05 wickx

apt install libicu should be enough i will add dependency

its-pointless avatar May 19 '17 07:05 its-pointless

f****** brilliant!

it's working. just did a quick install of quantmod, quandl, etc in R. couldn't be happing. it's the latest version of R as well.

i had been messing around with GNURoot Wheezy but this is far superior to anything else out there.

if anyone is wondering how to get R working on android. follow these steps:

  1. install termux
  2. edit your sources.list, by adding the link to the its-pointless repo (see above)
  3. add the key (i didn't bother)
  4. run an update: apt-get update
  5. install this lib: apt install libicu
  6. wait
  7. and finally: packages install r-cran

and you'll be good to go. thanks a lot for this, @its-pointless. this is definitely better than any of the other suggestions online. and i'm glad to see people contributing to termux development, it's a game-changer

wickx avatar May 19 '17 08:05 wickx

I'm having trouble installing the Rcpp package. I get this error message.

api.cpp:39:18: fatal error: 'execinfo.h' file not found #include <execinfo.h>

Does anyone have any tips or ideas?

namdnguyen avatar May 19 '17 14:05 namdnguyen

Android isn;t defined as an option but its easy to add defined(__ANDROID__). https://github.com/its-pointless/gcc_termux/tree/master/R-patches i will be putting any patches needed for r stuff there.

its-pointless avatar May 19 '17 21:05 its-pointless

just another update for anyone who's having issues with R on termux. there are a lot of additional packages you need to install within termux itself, make sure you do

packages install clang packages install libgfortran

amongst others (cant remember all of them). then, when you're in R itself, and you try to install quantmod (for instance)

install.packages('quantmod')

you'll get an error message that the gfortran command can't be found (even though you've installed libgfortran). in tht case, navigate to the

/usr/bin

directory and run this command

cp gfortran-6 gfortran

i have no idea if you're meant to do tht (??) but making a copy of this file with a title tht R recognises worked for me! i can pull financial data through quantmod and quandl and plot it inside a pdf. very happy. now i just have to figure out the equivalent of 'gnome-open' in termux, so tht i can open pdfs directly from the terminal...

wickx avatar May 23 '17 11:05 wickx

yeah i probably should of added more documentation. First thing install gcc-6 should install libgfortran. but if its not listed as a dep thats my fault.

Second point because clang is the default and gcc was removed i setup a script called setupclang and setupgcc-6 to switch between those 2 compilers. It also switches aarch64-linux-android-clang to be a symlink to gcc because of the way python configuration is set linking is sometimes done with aarch64-linux-android-clang not just just $CC. I should probably document it more but i honestly thought no one is going to use it but me so i stopped caring... anyway if you have any further suggestions im all ears.

its-pointless avatar May 23 '17 11:05 its-pointless

i'll use it! most definitely. i couldn't be happier right now. i just think a lot of people aren't aware tht this exists yet. all the various dependencies aside, getting R on android now basically comes down to installing termux and running one command. and considering how much i use R in my day to day job, this is really invaluable. thanks.

wickx avatar May 23 '17 12:05 wickx

Yes, I will second what @wickx said. It's been so helpful for me to have R available on my phone. I'm currently working on getting the tidyverse packages installed. Some of the packages installed (thanks to Rcpp and the gcc-6 compiler), but I think that others (such as stringi) require some fixes in the scripts to fix the shebang with termux-fix-shebang, and installing from source.

namdnguyen avatar May 26 '17 18:05 namdnguyen

Yeah issue with stringi is that it uses libicu-dev which needs cxxflags -std=c++11 to work if i remember correctly. Quickest solution is to use command setupgcc-6, build and install stringi then switch back to via setupclang . i will get a patch up in a bit.

its-pointless avatar May 26 '17 23:05 its-pointless

Also export CONFIG_SHELL=$PREFIX/bin/sh helps.

its-pointless avatar May 26 '17 23:05 its-pointless

Hello, I am having problems to install r-cran when I try to use packages install r-cran I get the output unable to locate package r-cran. I have installed the repository and even I have installed libicu. Thank you in advance,

cptrodolfox avatar May 31 '17 20:05 cptrodolfox

hey cptrodolfox, i'm going to use emacs in this example because tht's the text editor i use. feel free to use another. to install emacs, it's

packages install emacs

then, enter the following command to edit your sources.list file, this is the file tht determines what repositories you access when you do an install or update command

emacs $PREFIX/etc/apt/sources.list

once inside the file, move your cursor to the bottom of the file, and paste this line

deb [trusted=yes] https://its-pointless.github.io/files/ termux extras

once you've done that, hit ctrl+x ctrl+s to save and then ctrl-x ctrl+c to exit emacs. after you've exited emacs, run these commands

packages update packages install r-cran

and R should be installed. to launch R, just type the capitalised letter R on the command line and hit enter.

you'll prolly encounter more issues inside R once you start using it. report back what they are and i should be able to help you, as i currently have R running pretty flawlessly.

wickx avatar May 31 '17 21:05 wickx

Hi wickx, I have already have done that adding the repository and the key, and done the apt-get update. But, when I try packages install r-cran, It does not locate the package. It hits both repository the main termux and its-pointless one. Thank you in advance

cptrodolfox avatar May 31 '17 21:05 cptrodolfox

currently its only for arm and aaarch64. Since its compiled on device since R no longer support cross compiling. Is your device x86?

when you do apt update could you print the output here?

its-pointless avatar May 31 '17 22:05 its-pointless