1

I have a large data.frame loaded to memory in an R instance on one machine, and I'm using Rserve to allow access to this data from remote clients. I would like to be able to remotely make changes to the data.frame, like adding a column or changing a value, and I would like these changes to be available to other clients.

# server side
> xxx<-data.frame(a=1:3,b=4:6)
> run.Rserve(port = 6311, ...)

# client side
> cc<-RSconnect(port=6311, ...)
> RSeval(cc,'xxx$c<-7:9')
> RSeval(cc,'xxx')
  a b c
1 1 4 7
2 2 5 8
3 3 6 9

However, when I connect with a second client it does not see the changes:

# another client
> cc2<-RSconnect(port=6311, ...)
> RSeval(cc2,'xxx')
  a b
1 1 4
2 2 5
3 3 6

When the server is stopped the internal data is also unchanged. The changes are only available to the client that made them, not really what I need.

Is there some way to make this work?

Assaf Wool
  • 64
  • 4
  • I would either use a data base or an external flat file to be read/written by those distinct sessions. With `data.table` `fread` and `fwrite` you won't notice any overload assumed data are reasonnable. – Eric Lecoutre Feb 21 '17 at 07:54
  • Thanks, I was going to do that but then I found a way to do it directly using Rserve (see my answer below). – Assaf Wool Feb 22 '17 at 07:34

1 Answers1

0

Found it!! The answer was in the RSclient package manual, just had to reread it carefully.

The way to do this is by using RSserverEval. This command makes changes in the original server data, not the data available in the current connection. Thus the client making the changes cannot use them, only clients that connect later. It is a little annoying since the server will perform the command and it can't use data that the client created, but it does what I needed. It is important to note that the server must be configured to have control commands enabled (command enable in the configuration file)

Assaf Wool
  • 64
  • 4