Computational Mathematics

Adventures in Computing, Statistics, and R

R on the iPhone


iPhone users who have jailbroken their phone have been able to compile R for a while now since they have access to the command line via MobileTerminal.  However, I just recently found out that a package is now up on Cydia to ease installation. So I fired up my iPhone 4 and installed R on it just for fun using the instructions here.

I’ll write out the complete steps for installing R onto the iPhone here as they are actually quite simple:

1. Have a jailbroken iPhone and the Cydia package manager app installed
(instructions not provided here).

2. Install OpenSSH and MobileTerminal via Cydia
Note that if you are running iOS 4, the current version of MobileTerminal on Cydia does not work properly, you’ll need to get an updated version from:

MobileTerminal 354.3-12 Debian package

Copy the file to your iPhone via SFTP (or download it to your iPhone directly) and then install it via SSH using:

dpkg -i mobileterminal_364.3-12_iphoneos-arm.deb

3. Add a new repository to Cydia
In Cydia, go to Manage->Sources and Add the following repository:

4. Install R the Statistical Language
Use Search to find it, if you cannot, make sure your user level is either Hacker or Developer level under Manage->Settings because R is a command-line program so it will not show up if you are at the User level. You can change your level back to User immediately afterwards.

5. Run R from command line
Load up MobileTerminal and run R by simply typing:


Other notes

  • As it is based on command-line, plots are generated as files in the directory you start R in, as opposed to being displayed on screen.
  • Packages need to be installed and updated with the install.packages() and upgrade.packages() commands respectively
  • I recommend portrait mode as the keyboard seems to take up less screen estate but that’s just personal preference.
  • I’ve only tried this on iPhone 4′s retina display and it is barely usable so perhaps older iPhones would struggle with the readability.
  • As of the time of writing this post, the packaged R version is R 2.10.1. If you need a newer version, you will have to wait for an updated package or compile from source.

Thanks to ech0chrome for the Cydia repository and the reference instructions.

6 Responses

  1. [...] published a post about a package on Cydia to ease R installation on iPhone, you can read it here: R on the iPhone.Preface – I don’t use MacI don’t use Mac! Not that there is anything wrong with [...]

  2. I’d like to know your configs and if you could update/install packages without problems. I’ve installed R in my 3G running ios4.0.1 and ran into some issues. R installation was apparently flawless, but then I’ve noticed that iphone-gccplus was not installed because its dependence libgcc was lacking. As this library has reported problems in ios4, I downloaded and dpkg the package fake-libgcc, which is ok in ios4, as reported elsewhere. Cydia won’t install iphone-gccplus, leaving it in partial installation state. So, I installed iphone-gcc with headers as described by Anastas Stoyanovski for ios4. I received many error messages when trying to compile and install R packages. I could then install iphone-gccplus by dpkg, but this did not solve the problem. I’ve even could install toolchain 3.1.2 via dpkg, but nope. When I update MASS package, for example, along with many other error messages, R inform that it has detected a C compiler and a fortran compiler but that it cannot cross-compile. The package cmprsk, one of those I use more frequently, cannot be installed. I’d appreciate any glimpse into the dark.

  3. Apparently the Cydia Repo is down.
    Can someone confirm this?

  4. IFile (Cydia’s Finder, you could say) will install a downloaded debian package for you.

  5. Repo is still there, though nothing changed for mor than a year now. R works fine!

Leave a Reply