[R] JRI - problem to access "stats" package

Geoff Gibbs ggibbs at mango-solutions.com
Thu Jun 25 11:05:21 CEST 2009


Hi Antoine,

I have got this to work on Windows, the process should be the same for
Linux.

For an eclipse plugin you will need to add the following to your
MANIFEST.MF file: 

Bundle-ClassPath: <whatever you normally have>,
 lib/JRI.jar
Bundle-NativeCode: /lib/jri.dll; osname=winxp; processor=x86

You will also need to ensure that the R executable is in your path and
that R_HOME is set.

I did this by creating a simple batch file containing the following in a
directory called rootfiles within our feature, the same should work for
a .sh :

 set PATH=%CD%\<R install>\exe;%PATH%
 set R_HOME=%CD%\<R install>
 eclipse.exe

I then added the following line to the build.properties file of the
feature:
root=rootfiles

This tells eclipse to copy the content of the directory to the root of
the application on install.

If you then run eclipse from the batch file, it should work.

--

Geoff Gibbs
mangosolutions
data analysis that delivers

Tel +44 (0)1249 767 700

Mob +44 (0)7791 855 620


-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org]
On Behalf Of GRAN
Sent: 25 June 2009 09:40
To: r-help at r-project.org
Subject: [R] JRI - problem to access "stats" package

Hello,

I am a new R user. More precisely, I am working with JRI (on a Eclipse
Java6 project under Ubuntu9).

I have difficulties to access some R packages (For example: package
"stats", object "Normal", function "pnorm").

I have tried many solutions to set the right path but nothing have
succeed:
For example:
LD_LIBRARY_PATH=${R_HOME}/lib:${R_HOME}/bin:${R_HOME}/library

Inside the  java code, I have also tried such methods:
Note that "r" is the REngine object coming from the connection to R

           
r.eval("dyn.load(\"/home/gran/workspace/R-2.9.0/library/stats/libs/stats
.so\",
local = TRUE, now = TRUE)");
           r.eval("require(stats)");
           r.eval("autoload(\"Normal\", \"stats\")");
           r.eval("search()");
           r.eval("ls(\"Autoloads\")");
           System.out.println(r.eval(".Autoloaded"));
           r.eval("zval = .95");
           System.out.println(r.eval("print(zval)"));
           r.eval("p3 = pnorm(3*zval)");
           System.out.println(r.eval("print(p3)"));

It gives as a result:

           [STRING "stats"]
           [REAL* (0.95)]
           null       <---------- p3 = null because pnorm is unknown

Do you know how to use the "stats" package with JRI ?
Thanks in advance,
Antoine

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




More information about the R-help mailing list