File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other Languages and the fly likes Embedding R in other Applications Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Other Languages
Bookmark "Embedding R in other Applications" Watch "Embedding R in other Applications" New topic

Embedding R in other Applications

Robert Kabacoff
Ranch Hand

Joined: Mar 28, 2011
Posts: 33
Although not asked directly, there seems to be an implicit thread around how to embed R in other applications.

There are a large number of entry points in the R executable/DLL that can be called from C. See Writing R Extensions for details on the R API, as well as details for linking GUIs and other front-ends to R.

The RInside package provides C++ classes that facilitate embedding R functionality in C++ code on Linux, OS X, and Windows. An excellent blog on the subject can be found here.

Rserve is a "a TCP/IP server which allows other programs to use facilities of R from various languages without the need to initialize R or link against R library. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++, PHP and Java. Rserve supports remote connection, authentication and file transfer. Typical use is to integrate R backend for computation of statstical models, plots etc. in other applications."

There are many examples of calling R from Java, including rJava and RCaller.

There are numerous Web based inferfaces to R that take submitted code, runs R on the code (batch mode), and returns text and graphical output as web pages. See Rweb for an example.

I hope this helps.

Augusto Sellhorn
Ranch Hand

Joined: May 24, 2007
Posts: 57
Thanks for posting that, I was kind of trying to figure that out by asking if it was a JVM language.

It looks like rJava/RCaller are the things to look at for those of us in Javaland.

RCaller looks very simple to use, however one nice thing about JVM languages is their ability to call into existing Java libraries. Just by reading a bit about rJava it looks like it has a way to call from R->Java which can be very convenient for database drivers and libraries to things like data grids.
Oriol Boan

Joined: May 30, 2009
Posts: 15

Thanks Robert for this info.

I think most of us were wondering this issue, I mean, how to use R as a back-end for end-user applications written in other languages. As you may noticed from the thread about data mining and adaptive web, I was asking about this issue because one of the main use enterprises (e-commerce and e-learning) could take of a statistical language is to help them build web applications that can be automatically customized by customer preferences, customer web usages etc, i.e. the statistical language should act as a back-end for data/web mining processing to inform the application business logic on how to build user interfaces (based upon those data mining results).

I think R could have a great success in this role if projects as rJava could be properly addressed to be fully integrated with any of the popular j2ee frameworks.

Thank you again for your comments
Charles Caplan

Joined: Apr 20, 2011
Posts: 2
RCaller is great. I would definitely recommend using it to call R from Java as long as you realize that under the hood it is just calling RScript from the command line. But the API is wrapped in such a way that the calling code shouldn't care.
I agree. Here's the link:
subject: Embedding R in other Applications
jQuery in Action, 3rd edition