Sourcing r-files only once on Rserve
我写了一个小的Java客户端,它在Rserver上进行一些计算。为此,必须先获取服务器端的
当前,我在每个新连接上加载文件:
1 2 3 4 5 6 7 8 9 10 11 12 13 | import org.rosuda.REngine.Rserve.RConnection; public class RserveTester { public void doOnRserve() { RConnection c = new RConnection("rserve.domain.local" ); c.login("foo","user" ); c.eval("source("/home/rserve/lib/libraries.r")"); c.eval("source("/home/rserve/lib/functions.r")"); c.eval("someCalculation()" ) c.close(); } } |
其中
我的问题是:是否有可能只提供一次库,这样它们就可以在所有新的RSession中使用而无需单独采购?
我在客户端尝试过类似以下内容:
1 2 | c.serverSource("/home/rserve/lib/libraries.r" ) c.serverSource("/home/rserve/lib/functions.r" ) |
哪个给了我以下异常(不知道为什么
1 | org.rosuda.REngine.Rserve.RserveException: serverSource failed, request status: access denied (local to the server) |
我可以使用特定的
编辑:
基本上,接缝有三种可能的方法:
EDIT2:
Rserve版本v0.6-8(338)
用于x86_64-pc-linux-gnu的R版本2.15.2。
这很简单,只需在配置文件中添加
1 | source"/foo/bar.R" |
将在启动时提供
在文件路径中没有引号,可能会显示"找不到文件"错误。
BTW:您提到
PS:请使用stats-rosuda-devel邮件列表来解决Rserve问题。
是的,可以。永远记住这一点:
1 2 3 4 5 6 7 8 9 | R> fortunes::fortune("Yoda") Evelyn Hall: I would like to know how (if) I can extract some of the information from the summary of my nlme. Simon Blomberg: This is R. There is no if. Only how. -- Evelyn Hall and Simon 'Yoda' Blomberg R-help (April 2005) R> |
或作为
\\description{ Starts Rserve in daemon mode (unix only).
Any additional
parameters not related to Rserve will be passed straight to the
underlying R. For configuration, usage and command line parameters
please consult the online documentation at
http://www.rforge.net/Rserve. Use \\code{R CMD Rserve --help} for a
brief help.