R:如何在连接eval()函数中通过java传递rVector

时间:2018-01-24 06:54:56

标签: java r soapui

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)但不能这样做。有办法吗?

0 个答案:

没有答案