My project has some R
files prebuilt and I need to invoke them from Java layer
.
I cannot figure out a way to provide RScript
file path to RCaller
.
Need help to call RScript
file from RCaller Java
.
My project has some R
files prebuilt and I need to invoke them from Java layer
.
I cannot figure out a way to provide RScript
file path to RCaller
.
Need help to call RScript
file from RCaller Java
.
The script engine is planned for RCaller 3.0: http://mhsatman.com/rcallerscriptengine-a-scripting-interface-for-r-in-java-using-rcaller/
If you use Linux
, the path for RScript
is /usr/bin/Rscript
.
In Windows
, it depends on the version of R
, but you can find its location using the file browser and it follows a pattern similar to C:\\Program Files\\R\\R-3.0.2\\bin\\Rscript.exe
in a standard installation.
Addition to this, after detecting the path you can set it using
caller.setRscriptExecutable(pathToRscript);
if you want to get only one result per run and you can set the R location using
caller.setRExecutable(pathToR);
for online calculations, that is, if you perform calculations sequentially in a send-eval-get loop.
If you want your code to find out the path automatically, you can perform a recursive find for RScript
and R executables
. In an other way, using a FileDialog GUI
object, you can let the user find himself.
Now there are few other ways to call R Script from RCaller. After setting the Rscript Executable path. Using your RCode object(code) simply add code as-
code.addRCode("source('yourRscript.R')");
Or, you can directly call youRscript by the method
code.R_source("pathtoyouRscript");
then run your code from RCaller object using runOnly()
command.