pass data to R from java using jri -
i trying integrate r code inside java code.primary objective able use predictions on models created in r. able set environment , basic r commands working fine. issue: trying push data java r function.
code snippet:
rexp data=re.eval("newdata <- with(cbpp, expand.grid(period=unique(period), herd=unique(herd)))"); rexp fit=re.eval("predict(gm1,newdata,type=\"response\")"); //want pass data created in java newdata system.out.println(fit.asdoublearray().length);
in above code "newdata being populated r , used want able create own data in java , pass predict function in r. note: r code trying execute example lme4 package generalised linear mixed mmodel(glmm) model
it's been long time since used jri think can use assign()
. here's simple example passing array of doubles:
re.assign("newdata", new double[] {1.5, 2.5, 3.5});
Comments
Post a Comment