问题标签 [rjava]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1636 浏览

r - 集成 Java 和 R

我一直在寻找一些第三方 jar 来做一些高级的分析过程,比如 Java 中的 SQL 窗口函数,因为我们的数据库 mysql 不支持它。在谷歌的帮助下,我发现“R”虽然不是基于 java 的,但它可以解决我的大部分情况。我试过“RJava”和“Rcaller”接口来连接java。

对于性能、可扩展性和长期运行,这是在 Java 中连接 R 的最佳库。好心劝告。

0 投票
2 回答
3582 浏览

java - Using the Stanford NLP libraries from within R, using the rJava package

Does anybody have any experience with using StanfordCoreNLP ( http://nlp.stanford.edu/software/corenlp.shtml through rJava in R? I’ve been struggling to get it to work for two days now, and think I’ve exhausted Google and previous questions on StackOverflow.

Essentially I’m trying to use the StanfordNLP libraries from within R. I have zero Java experience, but experience with other languages, so understand the basics about classes and objects etc.

From what I can see, the demo .java file that comes with the libraries seems to show that to use the classes from within Java, you’d import the libraries and then create a new object, along the lines of:

From within R, I’ve tried calling some standard java functions; this works fine, which makes me think it’s the way I’m trying to access the Stanford libraries that’s causing the issue.

I extracted the Stanford ZIP to h:\stanfordcore, so the .jar files are all in the root of this directory. As well as the various other files contained in the zip, it contains the main .jar files:

  • joda-time.jar
  • stanford-corenlp-1.3.4.jar
  • stanford-corenlp-1.3.4-javadoc.jar
  • stanford-corenlp-1.3.4-models.jar
  • joda-time-2.1-sources.jar
  • jollyday-0.4.7-sources.jar
  • stanford-corenlp-1.3.4-sources.jar
  • xom.jar
  • jollyday.jar

If I try to access the NLP tools from the command line, it works fine.

From within R, I initalized the JVM and set the classpath variable:

After this, if I use the command

This shows that the directory containing the required .jar files has been added and gives this output in R:

[1] "H:\RProject-2.15.1\library\rJava\java" "h:\ stanfordcore"

However, when I try create a new object (not sure if this is the right Java terminology) I get an error.

I’ve tried creating the object in dozens of different ways (basically shooting in the dark though), but the most promising (simply because it seems to actually find the class is):

I know this finds the class, because if I change the class parameter to something not listed in the API, I get a cannot find class error.

As it stands, however, I get the error:

Error in .jnew(class = "edu/stanford/nlp/pipeline/StanfordCoreNLP", check = TRUE, : java.lang.NoClassDefFoundError: Could not initialize class edu.stanford.nlp.pipeline.StanfordCoreNLP

My Googling indicates that this might be something to do with not finding a required .jar file, but I’m completely stuck. Am I missing something obvious?

If anyone can point me even a little in the right direction, I’d be incredibly grateful.

Thanks in advance!

Peter

0 投票
1 回答
483 浏览

r - 从 JRI 保存大型 data.frame 时出现 Java 运行时段错误

我已经按照 rJava 安装中的 rtest.java 示例代码(Debian 和衍生产品上的 /usr/lib/R/site-library/rJava/jri/examples/rtest.java)从 java 数组构建 data.frames。

这适用于小数据帧(约 10000 行),但是当我愤怒地尝试执行此操作(即 > 1000000 行)时,它会导致 java 运行时出现段错误。

奇怪的是,我似乎能够创建 data.frame ok(进行通常的 rniPutXXXArray 调用),但是当我来保存 data.frame (使用 eval,在将 data.frame 分配给 R 符号之后)问题发生。

当我在 R 引擎上调用 eval 时,我可以看到一些调试,但是当我通过低级接口 (rniXXX) 时,我根本没有得到任何调试。有没有办法打开比我已经拥有的更多的调试?

对于它的价值,这里是 segv 消息的顶部。我当然可以根据要求提供更多细节。

0 投票
1 回答
347 浏览

r - 错误 rJava 64bit R&Eclipse

我一直在尝试切换到 64 位环境,但我遇到了 rJava 无法正常工作的问题。我已经关注了人们遇到相同问题及其解决方案(JDK、JVM.DLL、环境变量等)的线程,但我仍然卡住了

这是我得到的错误:

这是 R.version

提前致谢

0 投票
1 回答
1714 浏览

rjava - 安装和加载“rJava”

由于“rJava”的加载问题,我在加载“Deducer”包时遇到问题。“rJava”的安装似乎正确完成,但调用它加载时失败。

拜托,任何人都可以阐明一些智慧吗?:)

错误:'rJava' 的 loadNamespace() 中的 .onLoad 失败,详细信息:调用:stop("No CurrentVersion entry in '", key, "'!尝试重新安装 Java 并确保 R 和 Java 具有匹配的架构。")错误:找不到对象“键”错误:“rJava”的包/命名空间加载失败</p>

0 投票
1 回答
778 浏览

java - 集成 R 和 Hadoop(使用 JRI)

我已经看到了一些集成 R 和 hadoop 的选项,例如:RHadoop、RHipe、Hadoop Sreaming、RHive。

我在 R 中没有任何经验,但我在 Hadoop 中确实有很好的经验。我正在谈论的方法可能不可行或其他......

但是任何人都可以分享他们对这种方法的看法 -

我们可以使用 JRI 集成 R 和 Hadoop:因为可以从 Java 代码(使用 JRI)调用 R 函数。?我们可以这样做:用 Java 编写一个 hadoop mapreduce 程序,如果我们需要 R 中存在的一些功能,那么在 Java Mapreduce 程序中调用该 R-Function?

0 投票
2 回答
8241 浏览

r - 在 Win7 上加载 rJava 包时出现问题

我已经安装了最新版本的 R (2.15.2) 和 Java (7.11),并且通过 RStudio (0.97.310) 我正在尝试加载 rJava 包。它似乎安装正确,但是当我打电话时,library(rJava)我收到以下错误:

rJava 的文档引用了 Java 1.5+,所以我想知道是否需要安装 Java 的旧版本来解决这个问题。任何帮助将非常感激!

0 投票
1 回答
1225 浏览

r - mac上的openNLP

我不熟悉 Mac(我使用 Windows 和 Linux Mint),但我需要一个包,我需要能够告诉所有平台上的人们如何构建。该软件包依赖于openNLP并且由于 MacOS X 的编码问题,因此无法通过install.packages("openNLP").

有人告诉我您仍然可以使用安装,install.packages("openNLP", type="source")但我收到以下消息:

所以我使用 Mac 的终端来做建议R CMD javareconf

并尝试关闭 R,重新打开,然后install.packages("openNLP", type="source")出现相同的消息。谷歌在这里没有帮助我,我对 Mac 非常不熟悉。我认为这与安装的 java 类型有关,但对 Mac 知之甚少,无法漫无目的地玩,因为这不是我的 Mac 机器。

请指导我正确安装 openNLP。

0 投票
1 回答
1316 浏览

java - 在 Mac 上的 Java 应用程序中使用 R

这是我之前一篇关于在 Mac 上使用 R 和 JAVA 的后续文章。我的应用程序依赖于 R 来运行。我已经安装了 Java,Java 版本“1.6.0_37”。我已经安装了“R”,R 版本 2.15.1。现在我需要包含在rJava中的 JRI 。

在 R 内部,我运行了以下命令

install.packages('rJava',,' http: //www.rforge.net/ ')

这是输出:

我从这里去哪里?

启动tomcat时出现以下错误:

更新 2/15/13 尝试设置环境变量后...

我自己的路:

环境变量

JAVA_HOME 位置

R_HOME 和 JRI 位置

仍然收到上面的错误。

0 投票
1 回答
147 浏览

r - 尝试从 Web 应用程序使用 rJava 时出错

我在 Ubuntu 11.04 上使用 R 版本 2.15.2。JAVA_HOME变量设置为

为了能够使用rJava来自 RI 的负载,必须设置JAVA_HOME$JAVA_HOME/jre. 但是,我无法rJava从 R Web 应用程序调用的 R 脚本中使用。我已经开始JAVA_HOME/usr/lib/jvm/jdk1.6.0_21/jreenvvars但这个技巧不起作用。

有什么建议么?