gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 12:06:27 27 4
gpt4 key购买 nike

我不确定我这样做是否正确。

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

在选项卡 2 中,我打开 R,然后尝试连接到 Rserve。我通过以下方式做到这一点:

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

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

RSeval(c, name)

但它不起作用。我得到:

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

我在这里做错了什么?

最佳答案

我从 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()

关于r - 如何使用 R 客户端连接到 Rserve,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15314880/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com