[R] How can I call R from Java or C?

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Dec 11 08:03:53 CET 2003


On Wed, 10 Dec 2003, Aylin Yilmaz wrote:

> I am new to R. I have been looking for a way to call R functions from
> Java or C.
> 
> What I have found so far is: I can execute R commands in batch mode from a
> file and redirect the output to another file. However, I am not sure this
> is the way to do it.
> 
> About C, is it true that I can only call R from a C process,only if that C
> process is invoked within R itself? So is it R->C->R ?

Not true.  There are several ways to embed R in a C-based executable, but 
as you have not told us your OS, I won't elaborate.

> If I could call R from C, then I could possibly call C from Java using
> JNI (i am not sure exactly how well that will work)

Have you looked at the SJava package on the Omegahat site?

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list