double[] numbers = new double[]{1, 4, 3, 5, 6, 10};
code.addDoubleArray("x", numbers);
File file = code.startPlot();
System.out.println("Plot will be saved to : " + file);
code.addRCode("plot(x, pch=19)");
code.endPlot();
この例では値1、4、3、5、6、10の二重アレイを作成し、使用してRに渡す:
この非常に基本的な例としてはRCallerを使用してプロットを生成するためのアイデアを与えるだろうメソッドaddDoubleArray startPlotメソッドは、tempディレクトリに作成されるFileオブジェクトを返します。通常R発現
plot(x, pch=19)
プロットを描画ではなく、画面上ではなくメソッド() startPlotによって生成されたファイルに今回。メソッドendPlotを呼び出した後
()我々はので、すべてのディレクティブはRコードに変換し、Rに渡され、今、私たちはJavaでコンテンツを表示することができます
caller.runOnly();
を呼び出すことにより、プロセスを完成することができます
ここで code.showPlot(file);
は全体の一例です:
try {
RCaller caller = RCaller.create();
RCode code = RCode.create();
double[] numbers = new double[]{1, 4, 3, 5, 6, 10};
code.addDoubleArray("x", numbers);
File file = code.startPlot();
System.out.println("Plot will be saved to : " + file);
code.addRCode("plot(x, pch=19)");
code.endPlot();
caller.setRCode(code);
System.out.println(code.getCode().toString());
caller.runOnly();
code.showPlot(file);
} catch (Exception e) {
Logger.getLogger(SimplePlot.class.getName()).log(Level.SEVERE, e.getMessage());
}
あなたは電子のリンクを見ることができますXAMPLEここで与えられ、さらに読書:
Basic plotting using RCaller
Journal research paper
Unpublished research paper for RCaller 3