如何使用R客户端连接到Rserve

时间:2013-03-09 19:23:18

标签: r rscript rserve

我不确定我是否正确行事。

在选项卡1中,我打开R,然后在R会话中执行Rserve(port = 6311)。我加载变量“name = Hello World”

在标签2中,我打开R,然后我尝试连接到Rserve。我是这样做的:

  

c = RSconnect(host =“localhost”,端口6311)

然后我尝试通过以下方式打印hello world:

  

RSeval(c,name)

但它不起作用。我明白了:

  

RSeval(c,name)出错:找不到对象'名称'

我在这里做错了什么?

1 个答案:

答案 0 :(得分:4)

我从Rserve的作者那里得到了一些信息。 Rserve中更改的变量将在更改后连接到RSclient。特别是我得到了这些代码。

$ ~/bin/R CMD Rserve --RS-enable-control
$ ~/bin/R  
library(RSclient);
c=RS.connect();
RS.server.eval(c,"xx<-1");

## [1] TRUE

RS.close(c)

## NULL

c1=RS.connect();
RS.eval(c1,quote(yy<-xx));

## [1] 1

quit()
相关问题