Rserve - Eclipse & Java
Rserve - Eclipse & Java
您好,我正在根据本网站上的说明设置 rserve。
http://www.codophile.com/how-to-integrate-r-with-java-using-rserve/
但是在 eclipse 中使用 'eval'
时出现错误
double d[] = c.eval("rnorm(10)").asDoubles();
错误 - 'The method eval(String) is undefined for the type RConnection'
JARS 已正确加载到构建路径中并且 rserve 是 运行,但是我无法弄清楚为什么只有 eval 函数导致了问题。
除此之外还导入...
import org.rosuda.REngine.Rserve.RConnection;
导致错误 - 'The import org.rosuda.REngine.Rserve.RConnection conflicts with a type defined in the same file'
有人知道为什么会这样吗?谢谢
所有进口:
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
public class RConnection {
public int[] mean(String a[]) {
setupR();
return null;
}
public void setupR(){
try {
/* Create a connection to Rserve instance running
* on default port 6311
*/
RConnection c = new RConnection();// make a new local connection on default port (6311)
double d[] = c.eval("rnorm(10)").asDoubles();
org.rosuda.REngine.REXP x0 = c.eval("R.version.string");
System.out.println(x0.asString());
} catch (RserveException e) {
e.printStackTrace();
} catch (REXPMismatchException e) {
e.printStackTrace();
}
}
}
通过使用 import org.rosuda.REngine.Rserve.RConnection;
,您可以让 RConnection
在本地名称空间中为人所知。
但是,您已经在本地定义了一个名为 RConnection
的 class。
请重命名您的 class RConnection
,您应该可以导入 org.rosuda.REngine.Rserve.RConnection
.
您好,我正在根据本网站上的说明设置 rserve。 http://www.codophile.com/how-to-integrate-r-with-java-using-rserve/
但是在 eclipse 中使用 'eval'
时出现错误 double d[] = c.eval("rnorm(10)").asDoubles();
错误 - 'The method eval(String) is undefined for the type RConnection'
JARS 已正确加载到构建路径中并且 rserve 是 运行,但是我无法弄清楚为什么只有 eval 函数导致了问题。
除此之外还导入...
import org.rosuda.REngine.Rserve.RConnection;
导致错误 - 'The import org.rosuda.REngine.Rserve.RConnection conflicts with a type defined in the same file'
有人知道为什么会这样吗?谢谢
所有进口:
import org.rosuda.REngine.REXPMismatchException;
import org.rosuda.REngine.Rserve.RConnection;
import org.rosuda.REngine.Rserve.RserveException;
public class RConnection {
public int[] mean(String a[]) {
setupR();
return null;
}
public void setupR(){
try {
/* Create a connection to Rserve instance running
* on default port 6311
*/
RConnection c = new RConnection();// make a new local connection on default port (6311)
double d[] = c.eval("rnorm(10)").asDoubles();
org.rosuda.REngine.REXP x0 = c.eval("R.version.string");
System.out.println(x0.asString());
} catch (RserveException e) {
e.printStackTrace();
} catch (REXPMismatchException e) {
e.printStackTrace();
}
}
}
通过使用 import org.rosuda.REngine.Rserve.RConnection;
,您可以让 RConnection
在本地名称空间中为人所知。
但是,您已经在本地定义了一个名为 RConnection
的 class。
请重命名您的 class RConnection
,您应该可以导入 org.rosuda.REngine.Rserve.RConnection
.