views:

135

answers:

1

I created my own new R library (called "Media"). There is no problem when I try to load it with RGui, and I can call the functions defined in the new package. This is how I load it:

   > library(Media)

But, I'm also trying to call that functions from Java/JRI code, and when I load the new R package, Java doesn't seem to find the pacakge, throwing the message "Error in library(Media) : object 'Media' not found"

This is my current code using JRI:

    REXP rexpSetFolder = re.eval("setwd('C:/Users/Albert/Documents')");
    REXP rexpFolder = re.eval("getwd()");
    System.out.println(rexpFolder.asString());

    REXP rexpLoad = re.eval("library(Media)"); // fails

It also fails without the 'setwd' command, and simple calls to existing R functions work fine. I'm using R 2.10 and the latest JRI 0.5-0 under Windows.

Any help would be appreciated. Thank you very much.

Edit:

The parameter lib.loc seems to work, at least this sentence does not return an error:

library("Media", lib.loc = "c:/Users/Albert/Documents")

But after that, calling a function in the package with re.eval("myfunction()"); still fails, as the function is not properly found.

+1  A: 

Did you install the library properly first? You might want to try using the lib.loc parameter.

library("Media", lib.loc = "c:/Users/Albert/Documents")
Shane
I'll try it, but the strange thing is that I can execute the same code without problems directly in RGui. Thank you.
Guido
The sentence seems to work with the argument "lib.loc" but, after that, calling a function in the package called "media" with re.eval("media( t )"); still fails, with a message that says that it was not able to find "media" function...
Guido