我正在使用 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 如何决定q
在 R 代码的末尾添加一个(请参见下面输出中的倒数第二行)。这是怎么回事?请注意,当我打印输出时,那里没有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