Hi all, 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 ? 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) If you have any suggestions for R's interface that would be really nice. Thanks, ilene
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
Hi. Depending on what you are trying to do, you may also take a look at Rserve http://stats.math.uni-augsburg.de/Rserve/>From the webpage: "Rserve is a TCP/IP server which allows otherprograms to use facilities of R (see www.r-project.org) 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++ and Java.">From the Rserve FAQ: Supported Platforms: "Rserve should work on anyplarform supporting shared libraries which is also supported by R. The following platforms were tested and are known to work with the latest release: Linux (PPC, x86), Windows (x86), Mac OS X / Darwin (PPC), AIX (PPC since version 0.1-10), SunOS (sun4u since version 0.2)" I haven't used it myself so I do not know about the performance etc, but it looks like it is easy to get started with. Henrik Bengtsson Lund University> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Aylin Yilmaz > Sent: den 10 december 2003 23:48 > To: r-help at stat.math.ethz.ch > Subject: [R] How can I call R from Java or C? > > > > Hi all, > 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 ? > > 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) > > If you have any suggestions for R's interface that would be > really nice. > > Thanks, > ilene > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailma> n/listinfo/r-help