Bioequivalence and Bioavailability Forum

Main page Policy/Terms of Use Abbreviations Latest Posts

 Log-in |  Register |  Search

Back to the forum  Query: 2017-10-17 00:01 CEST (UTC+2h)

Running R on Android: library(PowerTOST) [R for BE/BA]

posted by VStus - Poland, 2016-09-27 19:54  - Posting: # 16687
Views: 3,563

(edited by VStus on 2016-09-28 09:02)

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

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).

#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):

#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  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
# wget

Successful download should look like this:
2. Install packages into R:
# R CMD INSTALL mvtnorm*

After this step, you should be able to run R with already installed packaged in console mode:
# R
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,

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:

Back to the forum Activity
 Mix view
Bioequivalence and Bioavailability Forum | Admin contact
17,394 Posts in 3,725 Threads, 1,071 registered users;
26 users online (0 registered, 26 guests).

The rise of biometry in this 20th century,
like that of geometry in the 3rd century before Christ,
seems to mark out one of the great ages or critical periods
in the advance of the human understanding.    R.A. Fisher

BEBAC Ing. Helmut Schütz