如何使用R客户端连接到Rserve [英] how to connect to Rserve with an R client
问题描述
我不确定我是否做对了.
I'm not sure if I am doing this right.
在选项卡1中,打开R,然后在R会话中执行Rserve(port = 6311).我加载变量名称= Hello World"
In tab 1, I open R, then I execute Rserve(port = 6311) inside the R session. I load the variable "name = Hello World"
在选项卡2中,我打开R,然后尝试连接到Rserve.我这样做是:
In tab 2, I open R, then I try to connect to Rserve. I do this by:
c = RSconnect(host ="localhost",端口6311)
c = RSconnect(host = "localhost", port 6311)
然后我尝试通过以下方式打印问候世界:
I then try to print hello world by:
RSeval(c,name)
RSeval(c, name)
但是它不起作用.我得到:
But it does not work. I get:
RSeval(c,name)中的错误:找不到对象'name'
Error in RSeval(c, name) : object 'name' not found
我在做什么错了?
推荐答案
我从Rserve的作者那里得到了一些信息.更改后,在Rserve中更改的变量将对连接的RSclient可用.特别是我使这些代码正常工作.
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()
这篇关于如何使用R客户端连接到Rserve的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!