RServe Java Source R script

Concept

There are two ways to source R script file in RServe Java program. The first way is to directly source it in the java code. The only disadvantage of this method is that each connection would need to do this. As an example consider the following R code

To source it directly in java

Another way to source palindrome.R is via the RServe.conf file. The file is present at /etc/Rserve.conf. If the file is not present then create a new one. Add the following line in the Rserve.conf file


If the default file is not used then specify the file on the command line

The java code remains same except that line 11 in the code above is deleted.

2 thoughts on “RServe Java Source R script

  • January 25, 2018 at 10:53 am
    Permalink

    Hi Mithil,
    Its a great example to get started with RServe. I was able to send the commands to be executed on the remote R server, but I wanted to execute a R script present in a remote location itself. Is that possible through Rserve? If yes, how?

    Reply
  • February 15, 2018 at 12:01 pm
    Permalink

    Hi,
    Thank you for the post. I have sourced the R script in my remote machine’s Rserv.conf file. But when executing I get the error :
    org.rosuda.REngine.Rserve.RserveException: eval failed, request status: error code: 127
    at org.rosuda.REngine.Rserve.RConnection.eval(RConnection.java:261)

    on this this line: c.eval(“palindrome(‘aba’)”);

    Why is it not reading the function from the sourced script, I’m wondering. FYI I didnt get any error in starting the Rserve with this conf file and the function is present in the script.

    Reply

Leave a Reply to Madhavi Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Bitnami