Running R on Android: library(PowerTOST) [🇷 for BE/BA]
Hi to all!
This post is intended to provide step-by-step HOWTO on installation of more-or-less recent version of R (3.2.5, “Very, Very Secure Dishes”) and latest version of PowerTOST package on Android devices.
In fact, most of modern smartphones are packed with quite powerful processors. As example: Samsung Galaxy S4 is approximately 40000 times more powerful than IBM System/360 Model 75J used by NASA to calculate Apollo flights trajectories (compared by Bogo MIPS). Thank's to Moore's law.
Example: R & PowerTOST in X11 via vnc viewer
![[image]](img/uploaded/image396.png)
Before you try: open this post in your Android's device browser, copy-paste of commands into terminal may be more convenient than typing. Check 'keyboard shortcuts' in GNURoot for more easy navigation with cursor keys and 'home' & 'end' buttons.
#Installation of programs from PlayMarket#
Programs to be installed from PlayMarket:
1. GNURoot (don't be confused, rooting is not required)
2. VNC Viewer (any VNC viewer shold work well, in fact, it's posible to connect via VNC from other device in local network).
![[image]](img/uploaded/image397.png)
#Configuring GNURoot#
Launch GNURoot and create Linux environment. I've tried WheezeX, because I'm familiar with Debian/Ubuntu. X means that minimal graphical system is onboard, so graphs could be displayed.
1. Create rootfs: select WheezyX
2. Run rootfs: WheezyX (to be able to install R and other Linux packages, mark 'run as fake root').
Now we are inside Linux console (bash-style):
![[image]](img/uploaded/image398.png)
#Configuring Debian#
Wheezy is an old version of Debian, so the R is outdated (2.5).
1. Adding R-Cran mirror with latest R backported to Wheezy (German mirror is selected by chance):
#Dowloading and installing PowerTOST#
PowerTOST as well as most other packages should be installed from source, as only limited number of r-cran packages for R 3.2.5 have been compiled for Wheezy.
1. Download PowerTOST and mvnorm source from r-cran:
Successful download should look like this:
![[image]](img/uploaded/image399.png)
2. Install packages into R:
After this step, you should be able to run R with already installed packaged in console mode:
![[image]](img/uploaded/image400.png)
It should be sufficient to run sample size estimations in your pocket. I may be wrong, but it seems that graphical output in console mode is automatically redirected to PDF files.
# Connecting to Linux X11 terminal via VNC Viever
1. Create new connection in VNC Viewer:
Link to VNC server - localhost:1 (or other number - check Linux console on start-up)
Password: "password"
2. Start VNC session.
PS: Performance
I'm not sure that code executed on all possible cores of your ARM processor.
Command above was completed in around 3 minutes, thus the smartphone is still significantly slower than by notebook (Core i5), where it took less than minute.
Please let me know if this is interesting/helpful.
Best regards,
Vstus
Small update: better console navigation is possible with Hacker's keyboard (PlayMarket), as it adds arrow keys and allows navigation of command history.
Disclaimer: use at your own risk!
Edit: Merged with a later post; you can edit your posts for 24 hours. [Helmut]
This post is intended to provide step-by-step HOWTO on installation of more-or-less recent version of R (3.2.5, “Very, Very Secure Dishes”) and latest version of PowerTOST package on Android devices.
In fact, most of modern smartphones are packed with quite powerful processors. As example: Samsung Galaxy S4 is approximately 40000 times more powerful than IBM System/360 Model 75J used by NASA to calculate Apollo flights trajectories (compared by Bogo MIPS). Thank's to Moore's law.
Example: R & PowerTOST in X11 via vnc viewer
![[image]](img/uploaded/image396.png)
Before you try: open this post in your Android's device browser, copy-paste of commands into terminal may be more convenient than typing. Check 'keyboard shortcuts' in GNURoot for more easy navigation with cursor keys and 'home' & 'end' buttons.
#Installation of programs from PlayMarket#
Programs to be installed from PlayMarket:
1. GNURoot (don't be confused, rooting is not required)
2. VNC Viewer (any VNC viewer shold work well, in fact, it's posible to connect via VNC from other device in local network).
![[image]](img/uploaded/image397.png)
#Configuring GNURoot#
Launch GNURoot and create Linux environment. I've tried WheezeX, because I'm familiar with Debian/Ubuntu. X means that minimal graphical system is onboard, so graphs could be displayed.
1. Create rootfs: select WheezyX
2. Run rootfs: WheezyX (to be able to install R and other Linux packages, mark 'run as fake root').
Now we are inside Linux console (bash-style):
![[image]](img/uploaded/image398.png)
#Configuring Debian#
Wheezy is an old version of Debian, so the R is outdated (2.5).
1. Adding R-Cran mirror with latest R backported to Wheezy (German mirror is selected by chance):
# echo "deb http://cran.uni-muenster.de/bin/linux/debian wheezy-cran3/" | tee -a /etc/apt/sources.list
# apt-get update
# apt-get install r-base-core r-base-dev
#Dowloading and installing PowerTOST#
PowerTOST as well as most other packages should be installed from source, as only limited number of r-cran packages for R 3.2.5 have been compiled for Wheezy.
1. Download PowerTOST and mvnorm source from r-cran:
# wget https://cran.r-project.org/src/contrib/PowerTOST_1.4-2.tar.gz
# wget https://cran.r-project.org/src/contrib/mvtnorm_1.0-5.tar.gz
Successful download should look like this:
![[image]](img/uploaded/image399.png)
2. Install packages into R:
# R CMD INSTALL mvtnorm*
# R CMD INSTALL Power*
After this step, you should be able to run R with already installed packaged in console mode:
# R
![[image]](img/uploaded/image400.png)
It should be sufficient to run sample size estimations in your pocket. I may be wrong, but it seems that graphical output in console mode is automatically redirected to PDF files.
# Connecting to Linux X11 terminal via VNC Viever
1. Create new connection in VNC Viewer:
Link to VNC server - localhost:1 (or other number - check Linux console on start-up)
Password: "password"
2. Start VNC session.
PS: Performance
I'm not sure that code executed on all possible cores of your ARM processor.
> system.time(pa.scABE(CV=0.36, theta0=0.9, targetpower=0.8, minpower=0.7, design="2x2x4", regulator="EMA"))
user system elapsed
218.810 0.410 226.017
Command above was completed in around 3 minutes, thus the smartphone is still significantly slower than by notebook (Core i5), where it took less than minute.
user system elapsed
13.68 0.58 14.64
Please let me know if this is interesting/helpful.
Best regards,
Vstus
Small update: better console navigation is possible with Hacker's keyboard (PlayMarket), as it adds arrow keys and allows navigation of command history.
Disclaimer: use at your own risk!
Edit: Merged with a later post; you can edit your posts for 24 hours. [Helmut]
Complete thread:
- Running R on Android: library(PowerTOST)VStus 2016-09-27 19:54 [🇷 for BE/BA]
- What about iOS DavidManteigas 2016-09-28 11:02
- R on iOS - only after jailbreak :( VStus 2016-09-28 14:31
- Generation Handy d_labes 2016-09-29 11:05
- Additional disclaimer and plans for future VStus 2016-09-29 11:16
- Additional disclaimer and plans for future Shuanghe 2016-09-30 09:19
- Additional disclaimer and plans for future VStus 2016-09-29 11:16
- Running R on Android: Notes and Questions mittyri 2016-10-02 21:27
- Running R on Android: correcting VNCserver startup error VStus 2016-10-04 21:56
- What about iOS DavidManteigas 2016-09-28 11:02