3

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?

user1103294
  • 423
  • 3
  • 6
  • 16

1 Answers1

4

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()
petermeissner
  • 12,234
  • 5
  • 63
  • 63
Indicator
  • 361
  • 2
  • 13
  • but in the server, I already declared that name = "hello world". I want to access that variable from the client. – user1103294 Mar 09 '13 at 22:33
  • For each client connected to the server, there is a unique context for that client. The context for each client is not overlapped with the context of the server. I also tried to define a variable on the server side, and access it from a client. However, this seems not working by far. I am using Rserve 0.7.1. – Indicator Mar 09 '13 at 23:23
  • I think it is possible for the server to share it's context to the client. This is actually the suggested solution for this same [problem](http://stackoverflow.com/questions/9936116/r-script-and-library-preloading/9936146#9936146) that I am trying to solve. We're both just probably missing a step. – user1103294 Mar 09 '13 at 23:33
  • I guess so. I have already sent an email to the author of Rserve. I will let you know if I got further information. – Indicator Mar 10 '13 at 00:05
  • it works! thanks for helping me debug it. and i never knew you could just message the author.... – user1103294 Mar 10 '13 at 04:03
  • Thank you for raising this question that motivates me to dig the problem deeper. Previously I was using an unperfect walkaround. – Indicator Mar 10 '13 at 04:24