how to connect to Rserve with an R client

梦想的初衷 提交于 2019-12-18 13:36:55

问题


I'm not sure if I am doing this right.

In tab 1, I open R, then I execute Rserve(port = 6311) inside the R session. I load the variable "name = Hello World"

In tab 2, I open R, then I try to connect to Rserve. I do this by:

c = RSconnect(host = "localhost", port 6311)

I then try to print hello world by:

RSeval(c, name)

But it does not work. I get:

Error in RSeval(c, name) : object 'name' not found

What am I doing wrong here?


回答1:


I got some information from the author of Rserve. The variable changed in Rserve will be available to RSclient connected after the changing. In particular I got these codes working.

$ ~/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()


来源:https://stackoverflow.com/questions/15314880/how-to-connect-to-rserve-with-an-r-client

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!