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

GRAN gran at teamlog.com
Thu Jun 25 10:39:44 CEST 2009


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




More information about the R-help mailing list