I have written a small Java client which does some calculations on an Rserver. For this purpose, there are functions.r
- and libraries.r
files on the server side, which have to be sourced, before the actual calculation can be done.
Currently I load the files on every new connection:
import org.rosuda.REngine.Rserve.RConnection;
public class RserveTester {
public void doOnRserve() {
RConnection c = new RConnection( "rserve.domain.local" );
c.login( "foo", "user" );
c.eval("source(\"/home/rserve/lib/libraries.r\")");
c.eval("source(\"/home/rserve/lib/functions.r\")");
c.eval( "someCalculation()" )
c.close();
}
}
where doOnRserve()
is called due to some events on the client side couple of times in a minute.
My Question is: Is it possibility to source the libraries only once, such that they are available during all new RSessions without individual sourcing?
I tried on the client side something like:
c.serverSource("/home/rserve/lib/libraries.r" )
c.serverSource("/home/rserve/lib/functions.r" )
Which gives me te following exception (no idea why this does not work wile eval
does):
org.rosuda.REngine.Rserve.RserveException: serverSource failed, request status: access denied (local to the server)
Can I start the Rserve with a specific .Rprofile
?
EDIT:
Basically, there seam to be three possible methods:
- Let the /home/rserve/.Rprofile source the .r files. But this seams to source them each time I call
new RConnection()
- Passing the source commands directly to R when starting Rserve (no idea how to do this).
- My preferred method: doing it from the client side using serverSource(), which throws these "access denied" exceptions.
EDIT2:
Rserve version v0.6-8 (338)
R version 2.15.2 for x86_64-pc-linux-gnu.
serverSource
both methods you mentioned don't work: Starting the daemon withR CMD Rserve --RS-enable-control --RS-conf ~/control/Rserve.conf
gives a warning on startup: "Warning: unkown Option '--RS-enable-control'". Addingcontrol enable
to (my local) Rserve.conf gives no warning but then I still get the Java exception: "serverSource failed, request status: access denied (local to the server)" – Padgett