A Java library providing a lightweight solution (~14 kB jar) for integrating R analytics executed on the OpenCPU server into any application running on the JVM. This library is ideally suited for integrating R analytics into new or existing server, middleware and cluster computing solutions.

The OpenCPU server provides an execution environment for scientific computing, reproducible research and data analysis based on R. To learn more about the OpenCPU server, see here. To learn more about the general capabilities of the R programming language and environment for statistical computing, see here.


This library provides the following OpenCPU integration support:


When working with this library the basic usage pattern is as follows:

 
OCPUTask rTask = OCPU.R().pkg(pName).function(fName).input(fInput).library();
OCPUResult rResult = rTask.execute();
Map rOutput = rResult.output();


For example, the following code snippet demonstrates the execution of the R stats::rnorm function:

Map data = new HashMap();
data.put("n", 10);
data.put("mean", 5);
OCPUTask rTask = OCPU.R().pkg("stats").function("rnorm").input(data).library();
OCPUResult rResult = rTask.execute();
Map rOutput = rResult.output();


The following code snippet demonstrates the execution of the R dpu.mobility::geodistance function by openmhealth on github:

Map data = new HashMap();
data.put("long", Arrays.asList(-74.0064,-118.2430,-74.0064));
data.put("lat", Arrays.asList(40.7142,34.0522,40.7142));
OCPUTask rTask = OCPU.R()
                     .user("openmhealth")
                     .pkg("dpu.mobility")
                     .function("geodistance")
                     .input(data)
                     .github();
OCPUResult rResult = rTask.execute();
Map rOutput = rResult.output();