Question

Is it possible to run R in Processing through rJava/JRI? If I deployed a Processing app on the web, would the client need R on their system?

I'm looking to create an interactive information dashboard that I can deploy on the web. It seems that Processing is probably my best bet for the interactive/web part of things. Unfortunately, it doesn't look like there are many math/stats functions built-in. And there aren't any libraries for plotting data either.

I've been using R and gpplot2 for a few months and am thrilled (amazed) at how easily it manipulates and plots data.

So I'm wondering now if can get the best of both worlds and run R through a Processing applet.

From the JRI website:

JRI is a Java/R Interface, which allows to run R inside Java applications as a single thread. Basically it loads R dynamic library into Java and provides a Java API to R functionality. It supports both simple calls to R functions and a full running REPL.

In a sense JRI is the inverse of rJava and both can be combined (i.e. you can run R code inside JRI that calls back to the JVM via rJava). The JGR project makes the full use of both JRI and rJava to provide a full Java GUI for R.

JRI uses native code, but it supports all platforms where Sun's Java (or compatible) is available, including Windows, Mac OS X, Sun and Linux (both 32-bit and 64-bit).

Thanks for the advice :)

Was it helpful?

Solution

Can you write Java code (or access a Jar file) in Processing? If so, then you can absolutely do this. JRI provides a low level interface to R and I have yet to encounter something in R that couldn't be run through its functions.

See this related question for simple example of how to use it.

I haven't really used Processing other than to look at it a few times, but it was my understanding that it had its own language.

OTHER TIPS

I wrote some example code along these lines last year:

http://illposed.net/R4P.html

Best,

Bryan

Another option is using the Incanter library for Clojure. It's an R-like library in Clojure, pretty fast due to the (pure java) Parallel Colt numerics library, with built-in JFreeChart support for quick charting as well as a wrapper for using Processing through Clojure.

You could just push the resulting app to the web as a normal (though probably pretty big) Java Applet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top