通过 rJava/JRI 在处理中使用 R?
是否可以通过 rJava/JRI 在处理中运行 R?如果我在网络上部署了一个处理应用程序,客户的系统上是否需要 R?
我希望创建一个可以部署在网络上的交互式信息仪表板。看来处理可能是我对交互/网络部分的最佳选择。不幸的是,看起来内置的数学/统计函数并不多。而且也没有任何用于绘制数据的库。
我已经使用 R 和 gpplot2 几个月了,我对它操作和绘制数据的轻松程度感到兴奋(惊讶)。
所以我现在想知道是否可以两全其美并通过处理小程序运行 R。
来自 JRI 网站:
JRI 是一个 Java/R 接口,它允许在 Java 中运行 R 应用程序作为单线程。 基本上它加载R动态库 转换为 Java 并为 R 提供 Java API 功能。它支持简单的 调用 R 函数和完整的 运行 REPL。
从某种意义上说,JRI 是 rJava 的反面 两者都可以结合起来(即你可以 在 JRI 中运行回调的 R 代码 通过 rJava 到 JVM)。 JGR项目 充分利用 JRI 和 rJava 提供完整的 Java GUI R。
JRI 使用本机代码,但它支持 Sun 的 Java(或 兼容)可用,包括 Windows、Mac OS X、Sun 和 Linux(均 32 位和 64 位)。
谢谢你的建议:)
Is it possible to run R in Processing through rJava/JRI? If I deployed a Processing app on the web, would the client need R on their system?
I'm looking to create an interactive information dashboard that I can deploy on the web. It seems that Processing is probably my best bet for the interactive/web part of things. Unfortunately, it doesn't look like there are many math/stats functions built-in. And there aren't any libraries for plotting data either.
I've been using R and gpplot2 for a few months and am thrilled (amazed) at how easily it manipulates and plots data.
So I'm wondering now if can get the best of both worlds and run R through a Processing applet.
From the JRI website:
JRI is a Java/R Interface, which allows to run R inside Java
applications as a single thread.
Basically it loads R dynamic library
into Java and provides a Java API to R
functionality. It supports both simple
calls to R functions and a full
running REPL.In a sense JRI is the inverse of rJava
and both can be combined (i.e. you can
run R code inside JRI that calls back
to the JVM via rJava). The JGR project
makes the full use of both JRI and
rJava to provide a full Java GUI for
R.JRI uses native code, but it supports
all platforms where Sun's Java (or
compatible) is available, including
Windows, Mac OS X, Sun and Linux (both
32-bit and 64-bit).
Thanks for the advice :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以在Processing中编写Java代码(或访问Jar文件)吗?如果是这样,那么你绝对可以做到这一点。 JRI 为 R 提供了一个低级接口,我还没有遇到过 R 中无法通过其函数运行的东西。
有关如何使用它的简单示例,请参阅此相关问题。
除了看过几次之外,我还没有真正使用过Processing,但据我了解,它有自己的语言。
Can you write Java code (or access a Jar file) in Processing? If so, then you can absolutely do this. JRI provides a low level interface to R and I have yet to encounter something in R that couldn't be run through its functions.
See this related question for simple example of how to use it.
I haven't really used Processing other than to look at it a few times, but it was my understanding that it had its own language.
去年,我沿着这些思路编写了一些示例代码:
http://illspoke.net/R4P.html
最好的,
布莱恩
I wrote some example code along these lines last year:
http://illposed.net/R4P.html
Best,
Bryan
另一种选择是使用 Clojure 的 Incanter 库。它是 Clojure 中的一个类似 R 的库,由于(纯 java)并行 Colt 数字库,速度相当快,内置 JFreeChart 支持快速图表,以及通过 Clojure 使用处理的包装器。
您可以将生成的应用程序作为普通(尽管可能相当大)的 Java Applet 推送到网络上。
Another option is using the Incanter library for Clojure. It's an R-like library in Clojure, pretty fast due to the (pure java) Parallel Colt numerics library, with built-in JFreeChart support for quick charting as well as a wrapper for using Processing through Clojure.
You could just push the resulting app to the web as a normal (though probably pretty big) Java Applet.