Find the code here: http://github.com/bwlewis/R4P.
Find R here: http://www.r-project.org.
Find Processing here: http://processing.org.


R4P helps Processing and R interact. It's distributed as an R package, but includes both R and Processing parts and is generally designed to be used from Processing.

Processing programs invoke an R engine using the Java-R interface (JRI) from the rJava R package. Many Processing functions are exposed to R scripts through a high-level interface function. Similarly, Processing programs may use R functions through the JRI interface. The package also includes a basic Processing output device for R graphics.

R4P includes a few example sketches that are installed into your Processing sketchbook directory.


Thus, R4P tries to make the languages relatively easily interoperable to obtain a system good at technical interactive graphics, animation, and scientific computing.

One of the included examples is a re-implementation of the "boids" bird flocking simulation included in Processing. The new implementation computes the flock motion in R but displays it with Processing. It also shows how R can handle simple mouse interaction (the position of a repulsor/attractor), as well as compute flock density "contours." Contour plots, somewhat tricky to produce natively in Processing, are one-liners in R. The example plot was produced by R plotting to the Processing output device using:


The example may seem somewhat contrived, but it does illustrate combining nifty features of each language. A video of the example appears below:

Note: if the above video does not display, try this link: http://illposed.net/boids.avi.


The R package includes the following basic documentation:
Basic Processing graphics device for R
High-level Processing function interface for R