I'm using RCaller in order to execute a R file in Java.
Basically, it looks like this:
RCaller caller = new RCaller();
RCode code = new RCode();
caller.setRscriptExecutable(PATH_TO_EXECUTABLE);
caller.cleanRCode();
code.R_source(PATH_TO_FILE);
code.addRCode("result<-test('" + param + "')");
caller.setRCode(code);
caller.runAndReturnResult("result");
... my problem is that I'm using Rcpp
in this R file (PATH_TO_FILE
) and it takes several seconds to compile this external C++ file in R. Therefore I want to reuse the function and not to compile this file all the time when I execute .runAndReturnResult(...)
.
The R file looks like this:
library(Rcpp)
sourceCpp("/cppTest.cpp")
myfunc<- test(param)
{
t<-cppTest(4)
return(t)
}
Does anyone have an idea how to achieve this using RCaller
or any other suggestions in case of other libraries which are capable of this?
Help is much appreciated! Thanks in advance, Chris