Skip to content

R on Mobile Devices (Android)

6 messages · Harsh, Barry Rowlingson, cruz +2 more

#
Hell R-list,

At the cost of sounding far-fetched and almost incredulous, I would
like to know if any R user is remotely considering the use of R on
Mobile devices, and Android in particular.

I really do not have an idea of the kind of definite incentives in
terms of using R on Android, but having an analytical engine on a
mobile phone would allow for micro statistics to be collected from the
log files reflecting number of calls dropped, average time spent
talking, a time series of the amount of time taken for battery
recharge, and a host of other information that could be collated and
analyzed.

R widgets could be created for analyzing the data streams from other
apps running on the same device.

Any thoughts/suggestions/information on this topic will be highly appreciated.


Thanks
Harsh Singhal
Decision Systems
Mu Sigma Inc.
Chicago, IL
#
2009/2/6 Harsh <singhalblr at gmail.com>:
First, rewrite R in Java. Good luck with that!

http://code.google.com/android/kb/general.html#c
I think having the analytical engine on the phone is probably not a
good idea for something that is pretty much connected all the time.
Better to have a lightweight data collection engine reporting back to
an analytical engine on a server somewhere. Then the analytical engine
generates reports on a web page.

 The data collection engine could do trivial summaries, statistics and
graphics in Java without needing R. If you wanted to do complex time
series analysis then that would be a job for the off-phone server.

Barry
#
On Fri, Feb 6, 2009 at 8:12 PM, Harsh <singhalblr at gmail.com> wrote:
Check out FreeRunner from Openmoko (http://wiki.openmoko.org/wiki/Main_Page).
It is a Linux based mobile device, and this is a FOSS project.
3 days later
#
Harsh wrote:
In addition to the other objections in the other replies, I add this 
one: the assignment operator and the parens are up on ALT keys on the 
Android keyboard.  Typing R expressions would be pretty painful.

You can demo this by installing an ssh client and logging in remotely to 
a machine with R on it, and trying to use it remotely.  A local one 
wouldn't be better...it might not even be faster, because the faster CPU 
on the machine running R might matter more than the speed of the network 
link between client and server.

I briefly thought of what it would take to port R to an iPhone or iPod 
touch, and the keyboard issues would be even worse.

Bottom line, R has the idiom of a real keyboard written into its bones. 
  To be popular, a statistical analysis tool for such devices would have 
to work differently, taking advantage of the platform's native input 
mechanisms.
I agree with the other person that the program to write to cover this 
case would be just a stat gatherer, which somehow gets the data off the 
device for analysis by R running elsewhere.  It could be a web service, 
or you could write a CSV file that somehow gets downloaded from the 
device for use on the computer the phone syncs to.
#
On Tue, Feb 10, 2009 at 7:57 PM, Warren Young <warren at etr-usa.com> wrote:
Just a note on porting to iPhone:
the iPhone keyboard can be customised for specific applications, so
you could make a keyboard with assignment and brackets prominently
displayed. I'm thinking that interface-wise this would be fairly
doable.
Unfortunately, I believe running R on the iPhone wouldn't be allowed.
The sdk states:

"3.3.2 [...]No interpreted code may be downloaded and used in
an Application except for code that is interpreted and run by Apple's
Published APIs and built-
in interpreter(s)."
and

"An Application may not itself install or launch other executable code
by any means, including without limitation through the use of a plugin
architecture, calling other frameworks, other APIs or otherwise."


I'm not too familiar with programming speech, but it seems this would
cover R, no?

Otherwise, I might be interested in porting R, taking it as an excuse
to learn objective C and C++....

regards,

Gustaf
#
Gustaf Rydevik wrote:
Mmmm...I think there's wiggle room here for a limited version of R.

The first clause says you couldn't have an R interpreter on the device 
that downloaded an R script and ran it.  It doesn't say you can't type 
an R script into the phone and run it there.  They're trying to block 
things like Flash and Silverlight with this restriction.  That, and the 
general security risks of running remotely-sourced content.

The second clause says install.packages() won't be allowed.  I don't see 
that it prevents you from distributing R with a pre-selected group of 
packages, however.

Keep in mind that all apps have to be approved by Apple, who haven't 
been entirely fair in their selection criteria.  And, you don't get to 
find out if they will accept the app until you finish it and submit it. 
  You risk wasting a lot of time, doing the port and then being rejected.

If you go ahead anyway, I hope you go beyond just customizing the stock 
keyboard.  I'd like to see:

- Instead of customizing the default keyboard, I'd rather have a 
calculator-like UI, with just a line or two of text at the top so you 
can see the expression, and the rest of the screen having an extended 
keyboard: letters, numbers, operator symbols, even custom buttons like 
an arrow button for assignment instead of having to type two math operators.

- Automatic parens, brackets, and quotes inference: when you've typed 
the name of a known function, add open and closed parens, and put the 
cursor between them.  In case of ambiguity -- can't do this for 
functions like print(), since you don't know if a dot is about to be 
typed to select a particular print method -- let user type open paren 
and add closed paren automatically.  Similarly, when the user types a 
bracket, quote, etc., supply the matching one and put the cursor between 
them.  Several text editors for Eclipse do this well, but not all.  A 
tricky bit is editing, where adding another quote, for instance, might 
not require the matching one to be added.

- Buttons for common functions, like plot()

- A button for downloading a data set from a web or FTP server and 
assigning it to a variable.  Basically, a wrapper around download.file() 
and read.table(), with automatic variable assignment and memory for the 
last variable name and URL used.

This is what I mean by changing the UI to match the capabilities of the 
device.

You'll probably end up excising a lot of stuff.  PDF support for 
instance: unless Cocoa Touch includes access to PDF rendering abilities, 
I don't know that I'd bloat the binary by adding it, particularly with 
the lack of a user-visible file system.  Yes, I'm aware that there are 
tools that let you poke around in the file system, but it's not the way 
the device is meant to be used.  Maybe you could justify it if there 
were a built-in way to send the generated PDF off elsewhere, such as an 
email attachment.

Bottom line: if it were available and worked well, I'd sure use it.  I 
just don't think a straight port would do it for me.