我想将R脚本运行到Eclipse中。
罐子:
环境(运行->运行配置->环境)
代码:
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import org.rosuda.REngine.REXP;
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
import org.rosuda.JRI.Rengine;
public class HelloWorldApp {
public static void main(String[] args) throws RserveException, REXPMismatchException, FileNotFoundException, IOException {
RConnection c = new RConnection("localhost",6311);
if(c.isConnected()) {
System.out.println("Connected to RServe.");
if(c.needLogin()) {
System.out.println("Providing Login");
c.login("username", "password");
}
REXP x = c.eval("1:10");
for(int i=0;i < x.length();i++)
{
System.out.println(x.asIntegers()[i]);
}
System.out.println("Reading script...");
Rengine r = new Rengine(args, true, null);
r.eval(" plot (x");
} else {
System.out.println("Rserve could not connect");
}
c.close();
System.out.println("Session Closed");
}
}
输出:
Connected to RServe.
1
2
3
4
5
6
7
8
9
10
Reading script...
Fatal error: you must specify '--save', '--no-save' or '--vanilla'
在Rstudio中发生了相同的错误:
library("Rserve")
Rserve()
输出:
Starting Rserve:
/usr/local/lib/R/bin/R CMD /home/mansi/R/x86_64-unknown-linux-gnu-library/3.1/Rserve/libs//Rserve
Fatal error: you must specify '--save', '--no-save' or '--vanilla'
因此,请帮助我解决此致命错误。
Try: Rserve(args='--vanilla')
我遇到了同样的问题,这对我有用。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句