How to plot using R, Java and JRI?

I am very new to R, so please forgive me if this is a very simple question.

I wrote an R script that does some calculations at the end of Box Plot graphics. If I run this script from the R console, it works fine and the graph will be plotted.

If I run the script from a Java program (an example of the rtest.java program, which is listed on the JRI site), the calculations work fine. But there is a problem with plotting. The frame window opens and remains busy and freezes. (If I try to click on the window, it shows "Do not respond.") I use the JRI.

This is how I draw a graph in a script:

boxplot(mat);

The above command works fine on the R-console.

I am sure that we are talking about some import / package or some similar settings. But unable to find out exactly what that is.

Can anyone help me with this?

Thank.

EDIT 1: Output of my drawer build command:

enter image description here

Output this code from the link provided by John:

enter image description here

+5
source share
1 answer

Here's how I did it: Pastebin link . Basically, you need to tell the R package JavaGDthat you have a JFrame available where R graphics can be displayed.

The example in @John Colby's answer simply stores the plot as a file and then displays it in Java - also an option, but a somewhat indirect way to do this.

( , Scala, Java ( Java), , . JRI , java.)

+4

All Articles