问题标签 [rserve]

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 回答
526 浏览

java - 如何在 Tomcat 上将 Rserve 与 JSP 一起使用?(Windows 7的)

我正在尝试使用 JSP 编写一个网页,该网页可以通过 Rserve 与 R 对话。

我已经安装了 R 和 Rserve 并且两者都在运行(我已经签入了任务管理器)。

我现在需要做的是在两者之间建立联系。我找到了 JAVA 的示例,但没有找到 JSP。我曾尝试编辑用作 JSP 的 JAVA 代码,但这总是给我与这段代码相关的错误:

我一直在使用这个问题的答案中的代码。

我是 JAVA 和 R 的新手,所以我可能错过了一些非常简单的东西......

0 投票
0 回答
438 浏览

rserve - Rserve/处理日志记录

我试图找出 R 和 Rserve 如何处理日志记录。我正在使用 Rserve(连接到 Java 代码)在守护程序模式下运行 R。日志记录功能可以关闭吗

0 投票
3 回答
3702 浏览

r - 如何指定 R CMD exec 目录?

以前我可以通过以下方式从命令行启动 Rserve:

在 Ubuntu 上升级到 3.0.2 后,我得到:

我尝试通过手动重新安装和启动

...效果很好。

R CMD Rserve 仍然失败,并出现与上述相同的错误。我尝试通过以下方式指定路径:

如何说服 R CMD 使用正确的目录?

0 投票
1 回答
201 浏览

sql - 在 SQL 查询中使用 R 变量

我在 Java 中使用 RServe 和 SQL 从数据库中获取数据并将结果绘制在 R 图中。这工作正常,但现在我需要在 SQL 查询中使用一个变量。

在 PHP 中,我知道您只需要关闭语句、添加变量并重新打开语句。

但是,当我在 Rserve 中尝试此操作时,页面会挂起。

我的代码如下:

没有WHERE UID=\"'+UID+'\"代码就可以完美运行,所以我知道这是问题所在,我只是不知道解决方案?

注意:我也尝试过使用 , 而不是 + ,如this answer中所述,但这似乎也不起作用。

0 投票
1 回答
236 浏览

java - 处理 JSP/Rserve 网页上的空 R 数据框

使用 JSP 网页和 Rserve,我从 MySQL 数据库中获取数据并使用 R 数据框来存储数据。这工作正常并且情节完美。

但是,如果 db 查询不返回任何内容,则数据框为空,并且在尝试绘图时会引发错误。

我想要做的是重定向到另一个 JSP 页面,然后该页面将显示错误,但我不确定如何执行此操作。

我找到了这个 R 代码(它的作用纯粹是为了测试目的),它告诉我数据框是否为空,但是我怎样才能包含 Java(或其他东西)来重定向页面?

编辑:我已经设法做到了这一点:

“失败”不会打印(我真的没想到会打印),但正如上面在 else 中所说的那样,我想要一个重定向。关于这怎么可能的任何想法?

0 投票
3 回答
2612 浏览

r - 在 Mac OS X Maverick 上启动 Rserve 时出错

我正在尝试在 R 控制台中使用 Rserve() 命令启动 Rserve,但出现错误/Library/Frameworks/R.framework/Resources/bin/R: line 141: exec: sh: not found

我有 Mac OSX Maverick。我安装了 R 版本 3.1.0。在此之后,我尝试使用命令install.packages("Rserve")安装 Rserve ,之后以红色显示的消息是

在此之后,我在 R 控制台中给出了命令库(Rserve)并且没有出现错误,但是当我给出命令Rserve()来启动服务器时,我得到了我上面提到的错误。

我无法理解为什么会出现这个错误。是不是因为Rserve没有安装成功?Rserve 还能如何安装?我也尝试通过源包安装 Rserve。我从 rforge 网站下载了源包,当我给出命令install.packages("Rserve", type = "source")时,我得到的错误是: installation of package ‘Rserve’ had non-zero exit status

任何帮助都会很棒!

0 投票
1 回答
3679 浏览

java - Error while executing R commands in Java for accessing data from PostgreSQL and doing computation

I am writing a Java code where in I am trying to get the data from PostgreSQL and doing simple computation on it(calculating median). First I am loading the RPostgreSQL library from Java code itself and then loading the driver and establishing the connection between R and PostgreSQL through Java. But when I am trying to fire a query command(which is used to get query from PostgreSQL to R) through Java then I am getting error as:

NOTE:THIS ERROR IS RESOLVED.PLEASE LOOK BELOW FOR CURRENT ERROR(Script File Error)

My current code is :

I don't think that there is any problem with Rserve connection as for simple code like displaying version of R it is getting executed correctly.

Also there is no problem with the syntax of writing commands for R to PostgreSQL part like the dbSendQuery() or similar as when I using them directly from within R they are working perfectly fine. So, the problem that I think is in writing the same in Java(corresponding syntax for Java).

UPDATE 1: ERROR 2 (THIS ERROR IS RESOLVED)

After taking suggestion from @ on_the_shores_of_linux_sea I have modified my code a bit but now a different error is coming as:

I am not able to figure out why the error is and how to resolve it

SECONDARY QUESTION: This a secondary question as I also want to know that is it possible that I can write the R queries or statements in a file(a special R format file or any other format file) and then make Java read the file and push the R commands into R so as to execute them?

UPDATE 2: SCRIPT FILE ERROR

The method 1 mentioned by @on_the_shores_of_linux_sea below is working fine now. I am also trying to do through method 2 but having some difficulties in managing script through Java. The Java code that I am using is:

The error on output console that is getting printed is as:

My script file syntax is:

I am not sure whether the error is in script file or my Java syntax.

0 投票
2 回答
5035 浏览

r - Rserve 安装错误

我想在 Eclipse 中运行一个 R 脚本。

  • R 3.1.1
  • Ubuntu 12.04
  • 日食开普勒
  • 罐子:

    • JRI.jar
    • REngine.jar
    • RserveEngine.jar
  • 环境(运行 -> 运行配置 -> 环境)

    • R_HOME:/usr/local/lib/R

代码:

输出:

Rstudio 中也出现了同样的错误:

输出:

所以请帮我解决这个致命错误。

0 投票
1 回答
2319 浏览

java - 如何将文件路径传递给使用 Rserve 在 Java 中调用的 Rscript?

我正在使用 Rserve 通过我的 Java 项目访问 R 脚本。java 代码要求用户输入文件位置并存储在字符串变量中。然后将该变量传递给应该读取文件位置的 R 函数。但这样做我得到以下错误:

这是我的java代码:

这是我的 R 函数:

有人可以帮我解决这个问题吗?

0 投票
2 回答
2172 浏览

java - 如何使用 Rserve 从 Java 中的 R 脚本导出数据?

我正在使用 Rserve 通过我的 Java 项目访问 R 脚本。java 代码要求用户输入文件位置并存储在字符串变量中。然后将该变量传递给 R 函数,该函数应该读取文件位置执行一些过程,然后创建一个新文件夹并将处理后的数据写入单个文件中,然后在控制台上打印出所有文件都已生成。我最初用较小版本的程序检查了 R 连接,它工作正常。但是,当我包含将数据写入文件的步骤时,它显示以下错误:输入文件路径:

此外,代码也不会在控制台上打印任何必须通过 R 从 Rscript 打印的语句。这是Java代码:

而且,这里是 R 脚本:

有人可以帮帮我吗?