1

RCaller を使用して Java から R を呼び出しています。次の Java コードを参照してください。

RCaller caller = new RCaller();
RCode code = new RCode();
caller.setRscriptExecutable("/usr/bin/Rscript");
caller.cleanRCode();

String x = "is.installed <- function(mypkg){ \n" +
               "is.element(mypkg, installed.packages()[,1])\n"+
           "}\n" +
           "is.installed(\"bbmle\")";
StringBuffer s = new StringBuffer(x);
code.setCode(s);

System.out.println(x);
caller.setRCode(code);
caller.redirectROutputToConsole();
caller.runOnly();

これが Java の出力です。Rcaller がqR コードの末尾に a (以下の出力の最後の 2 行目から参照) を追加することを決定したことに注目してください。これは何ですか?出力を印刷すると、そこには何もないことに注意してくださいq

is.installed <- function(mypkg){ 
is.element(mypkg, installed.packages()[,1])
}
is.installed("bbmle")
Error:Error: unexpected symbol in "is.installed("bbmle")q"
Error:Execution halted
4

1 に答える 1