开发者

RMySQL package doesn't load through JRI interface

开发者 https://www.devze.com 2023-03-25 18:37 出处:网络
I\'ve managed to install RMySQL in R, and it runs fine (I also installed its required dependency, DBI, and it works fine too). I\'m building a java application that interacts with R through the JRI pa

I've managed to install RMySQL in R, and it runs fine (I also installed its required dependency, DBI, and it works fine too). I'm building a java application that interacts with R through the JRI package (which also works fine). Currently my application queries a MySQL database, writes the query results to file, and loads these files in R (by using the load.csv() function in R). However, the program would run more efficiently if R were to interact directly with MySQL (hence the RMySQL package). The problem that I'm having is that the RMySQL package will not load in R if I try to load it by using the Rengine.eval() JRI function. However, the Rengine.eval() function will load any other library that I've tried loading. Here's a snippet of the code:

Rengine re;

re.eval("library(\"DBI\")"); // this works, DBI will load
re.eval("library(\"RMySQL\")"); // this will not work, RMySQL fails to load

To verify that RMySQL is failing to load I did this:

REXP x;
System.out.println(x=re.eval("library(\"DBI\")"));
System.out.println(x=re.eval("library(\"RMySQL\")"));

I get the following output:

[STRING* ("DBI", "stats", "graphics", "grDevices", "utils", "datasets", "methods", "base")]

null

As can be clearly seen, the second println command is returning a null which means that the RMySQL is failing to load (and of course none of the RMySQL functions work either). I have no idea why this is the case.

I don't know what it is I'm doing wrong, but if someone can tell me what the problem is, or if there is a better way of loading libraries through JRI I would much appreciate it.

Note that I am using R version 2.13.0 on sparc-sun-solaris2.10, and the RMySQL_0开发者_运维技巧.8-0 build.


Resolved this issue by setting the environment variables R_HOME, R_INCLUDE_DIR, R_SHARE_DIR, and R_DOC_DIR before running JRI. Works now great.


I had this type of problem before.

You probably installed RMySQL package not the correct way, e.g.

install.packages('RMySQL')

The correct way will be:

install.packages('RMySQL',type='source')

I succeeded to load the package through JRI after i installed the package with type "source".

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号