Calling Charts from R to a Java Application

Hi guys I want to ask, is there anyone who successfully works with JRI and rJava? I want to put some graphics, graphics made in R, in my Java application, but to no avail. Can anyone provide a working example. Here is what I found, but it does not work. thank you

import org.rosuda.JRI.REXP; import org.rosuda.JRI.Rengine; /** * @author Nero *In this file, i will try to plot a simple example, only to test how it?s possible to plot through java *Attention: Nothing will work if you have not included the JRI.jar as library ( through properties)*/ public class TryPlot { public static void main(String[] args) { // TODO Auto-generated method stub //start the Rengine (JRI) Rengine re = new Rengine(null, false, null); //in R: >a<- c(1.2,2.3,4.5) : double da[] = {1.2, 2.3, 4.5}; long xp3 = re.rniPutDoubleArray(da); re.rniAssign("a", xp3, 0); //look up for a: REXP x; x = re.eval("a"); System.out.println(x); //THE PROBLEM: The window opens, but nothing happens??? re.eval(" plot(a)"); } } 
+4
source share
1 answer

I think that a regular R graphics device only works if you use it in the R GUI, and not when starting from java or command line. So I used the "JavaGD" package as a graphics device, and it works great. The plot is printed in a regular JFrame, which can even be expanded by subclassing it.

+2
source

All Articles