5

I tried RCaller 2.0 to call R functions from Java and I managed to make it work after a few tries. Integration was pretty easy but RCaller is kinda slow at runtime. I'm afraid that RCaller 2.0 won't be suitable for my application since I have to repeatedly call the same script thousands of times and the latency introduced by this library is unacceptable for my needs.

Is there a faster (in terms of run-time execution time) alternative for calling R scripts from Java?

jbytecode
  • 681
  • 12
  • 29
Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
  • I assume you are aware of rJava. Any reason that it is not suitable? – Ian Fellows Sep 15 '11 at 20:09
  • I never integrated Java/R together and RCaller 2.0 seemed the easiest solution. I heard about rJava and about Rserve as well, which one would you recommend? There are also work in progress about Renjin but it might be too early for it.. – Marsellus Wallace Sep 16 '11 at 14:40

4 Answers4

2

Have a look at the test file in RCaller source tree: https://code.google.com/p/rcaller/source/browse/RCaller/src/test/java/rcaller/RunOnlineTest.java

This test file includes sequential commands that run on a single R process. This way is said to be fast.

phpcoder
  • 51
  • 2
2

Rcaller has many performance improvements that came with the version 2.1. It now supports passing commands to R in a loop using a single R process. That is, there is no more system calls after the initializing process.

jbytecode
  • 681
  • 12
  • 29
  • This [link](http://stdioe.blogspot.com/2011/09/rcaller-support-for-sequential-commands.html) would help for faster solution – jbytecode May 14 '13 at 18:07
1

Is there any way to push some of the iteration over into R, so that you're calling it much less often? Maybe you can pass in an array of data, with an array of scripts to run, where you're passing them in one by one now.

Ed Staub
  • 15,480
  • 3
  • 61
  • 91
  • This is often a good approach to take with interaction between systems, given that the cost of each call is often much higher than one with a larger transfer of data. – obfuscation Sep 15 '11 at 19:22
  • @Ed: right, but I don't have full control over the R script (and I know nothing about R), so this might be an issue for me. Also, I would lose full control over exception handling if anything goes wrong for a given input... – Marsellus Wallace Sep 16 '11 at 14:45
  • 1
    @Ed: well.. this was actually my final implementation and it dramatically improved total execution time. RCaller won't beat rJava and rServe at runtime but its simplicity played an important role this time. Rnjine might be the way to go soon: http://stdioe.blogspot.com/2011/09/embedding-r-in-java-applications-using.html; – Marsellus Wallace Sep 20 '11 at 03:08
0

Try Renjin, it seems pretty fast at least!

Dave Jarvis
  • 30,436
  • 41
  • 178
  • 315
Makoto
  • 1,520
  • 2
  • 12
  • 19