R代码
abc <- function(theta,y) {
a <- y[1]
b <- y[2]
c <- y[3]
p <- c/(1+(a*(theta-b)))
return(p)
}
Java代码
RConnection connection = new RConnection();
connection.eval("source('D:\\\\file.R')");
double theta = 7
double a = 5
double b = 9
double c = 2
double y = "c(a,b,c)" // 'y' is R vector of length 3 (one-dimensional array)
with a, b, and c parameters as elements
double sum = connection.eval("abc("+theta+","+y+")")
log.info("The sum is=" + sum);
问题
我想在eval函数上传递vector(y)但不能这样做。有办法吗?