问题描述
我有一个现有的Javascript/HTML应用程序.我想使用R Programming
的科学计算和图形功能.
I have an existing Javascript/HTML Application. I wanted to use power of R Programming
's scientific computing and graphics.
我的目标是,
- 从Javascript应用发送一些数据.
- 使用数据输入调用预定义的R函数.
- 获取输出以文本和图形的形式获取输出.
- 在HTML页面中显示它.
如何实现这一目标,
-
我应该连续运行R,使用
web sockets
之类的东西并连接到R吗?如果正在执行如何传递R脚本以执行并获取输出包?
Should I run R continuously, use something like
web sockets
and connect to R? If doing How to pass R scripts to execute and get the output pack?
有 Rserve . Rserve
有一些nodeJS
实现.但这是问题,每一行代码都应通过evaluate
命令传递.即使我这样做,如何处理图形输出?
There is Rserve. There are some nodeJS
implementation for Rserve
. But problem with this is, each line of code should be passed through the evaluate
commands. Even though if I do so, how to handle the graph output?
我探索了一些 openCPU .如果使用openCPU R程序包,则R应该使用opencpu
库连续运行,并且我们分别启动R和openCPU,它以不同的端口号开头.如果我关闭R会话,opencpu
服务器也会终止.
I explored a bit of openCPU. If using openCPU R package, R should be continuously Running with opencpu
library and each we start R and openCPU, it starts with different port number. And if i close the R session, opencpu
server also terminates.
如果我在计算机上安装了独立的opencpu
服务器,该如何在其中使用R?我已经安装了openCPU独立服务器,并在此之后卡住了.
If I install standalone opencpu
server in my machine, how to use R with this? I've installed openCPU standalone server and a kind of stuck after that.
我应该如何进行,应该怎么做才能完成任务.我有点不知道该往哪个方向走.请对此加以说明.我敢肯定大多数人都需要这个.
How should I proceed, What should I do to accomplish my task. I'm like a kind of don't know which direction to go. Please throw some light on this. I'm sure most people would need this.
我已经使用过shiny
,但是在这种情况下,我无法使用它.需要从外部Web应用程序连接R.
I have worked with shiny
, but in this case, I can not make use of it. Need to connect R from external Web Application.
推荐答案
FastRWeb 听起来像是完美满足您的需求.从文档中:
FastRWeb sounds like it would be perfect for your needs. From the documentation:
run <- function(n=10, ...) {
p <- WebPlot(800, 600)
n <- as.integer(n)
plot(rnorm(n), rnorm(n), col=2, pch=19)
p
}
然后可以使用JavaScript来调用它以动态加载图像并显示它们.
This can potentially then be called using JavaScript to dynamically load images and display them.
您可能还想考虑发亮,尽管这是一个完整的解决方案.
You might also like to think about shiny, though that's more of a complete solution.
这篇关于将R及其图形与现有Javascript/HTML应用程序集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!