|
How to start Rserve?
Rserve runs but neither Rcli nor JRclient are able to connect
How do I get textual output of commands from Rserve?
How can I retrieve multidimensional arrays or matrices from R?
How can I debug Rserve or see the structure of the evaluated data?
What is the format of the passwords file?
What are the limits of Rserve in terms of data size?
Which platforms/operating systems are supported by Rserve?
Where are Rcli and C/C++ client sources?
|
|
How to start Rserve? |
|
Type:R CMD Rserve in the shell/terminal. You should get something like this:
R : Copyright 2003, The R Development Core Team
Version 1.7.0 Patched (2003-05-06)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type `license()' or `licence()' for distribution details.
R is a collaborative project with many contributors.
Type `contributors()' for more information.
Type `demo()' for some demos, `help()' for on-line help, or
`help.start()' for a HTML browser interface to help.
Type `q()' to quit R.
Rserv started in daemon mode.
You can check whether Rserve runs with:
ps ax|grep Rserve
(or ps -A|grep Rserve depending on your unix). You should get something like this:
2822 ?? Ss 0:00.73 /usr/local/lib/R/bin/Rserve
Windows users: Start Rserve by double-clicking on the Rserve.exe file. While it is running it will appear in the task manager and there should be an output window. |
Rserve runs but neither Rcli nor JRclient are able to connect |
|
If you are running Rserve in local mode (which is the default), you must use the same machine for both the server and the client. Make sure you have no local firewall software running. The default Rserve port is 6311, make sure it is accessible. You can test whether Rserve responds by typing telnet localhost 6311
If Rserve works, you should get:
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Rsrv0100QAP1
--------------
If you're trying to connect a remote Rserve, make sure remote access is enabled in the config file of the server (remote enable must be in the config file). You can test whether Rserve responds with the telnet command as in local connect case. Also check that there is no firewall between the client and the server, or that it is configured properly.
|
How do I get textual output of commands from Rserve? |
|
Rserve doesn't return any output printed by the evaluated expressions. The idea is to return data in binary form, which is faster and more flexible. Nevertheless sometimes it may be convenient to simply reproduce the printed output given in R (such as a model summary). The R function capture.output can be used for that purpose - it returns a vector of strings (each entry correspnds to one line of output).
An example:
String s=c.eval("paste(capture.output(print(summary(mymodel))),collapse=\"\\n\")").asString();
System.out.println(s);
Note: Don't forget to use print function if you want any output, because the code is executed as if it was in a function, NOT like command line!
|
How can I retrieve multidimensional arrays or matrices from R? |
|
since JRclient-DA08: For matrices or 2-dimensional arrays see asDoubleMatrix/asIntMatrix accessor methods in REXP.
older JRclients and >2 dimensional arrays:
R stores multidimensional arrays internally as vectors with dimensionality information attached. Since Rserve uses the same representation of data as R, an array is passed as a vector with an attached attribute containing the dimensions. The following Java code shows how to retrieve it:
REXP r=c.eval("array(1:6,dim=c(2,3))");
int[] dim=(int[]) r.getAttribute().asList().getHead().getContent();
int[] value=(int[]) r.getContent();
The dim array contains the dimensions of the R-array and the value array contains the actual contents.
|
How can I debug Rserve or see the structure of the evaluated data?
|
|
There is a special debug version of Rserve which displays a lot of information when run, among others all packets sent and results on the R side. By default it is compiled along with the regular version and can be found in the $RHOME/library/Rserve directory as Rserve.dbg. The easiest way to use it is to copy the Rserve.dbg file into $RHOME/bin and run it via
R CMD Rserve.dbg
Unlike the regular version this one doesn't daemonize but prints everything on the stdout. It is really verbose and much slower than the regular version, so use it for debugging purposes or if you want to analyze the R objects resulting from the evaluation.
BTW: Since 0.3-3 you can specify the number of array elements and dumped bytes that are printed. Use --RS-dumplimit <amount> command line parameter to change that setting. Default is 128 and specifying 0 means no limit.
|
What is the format of the passwords file?
|
|
It is a plain text (ASCII) file of the form
user password
one line for each user, password in clear text (so make sure you restrict the permissions on the file correspondingly). The user/password has nothing to do with your system users, so feel free to use anything.
|
What are the limits of Rserve in terms of data size?
|
|
Limits in versions up to 0.2-x:
- Maximum size of a single REXP: 16MB (both ways, fixed)
- Default packet size: 2MB (max. 1GB) configurable via CMD_setBufSize resp. setBufferSize in JRclient
Limits in version 0.3:
- Maximum size of a single REXP: 2GB (on 32-bit platforms), theoretical limit is 2^55 on 64-bit platforms.
- Packet size is auto-adjusted, configured by maxinbuf and maxsendbuf config entries. (maximum 2GB)
The maxinbuf (max. packet from client to Rserve) and maxsendbuf (max. packet from Rserve to client) options in the configuration file allow you to set limits in order to prevent memory overflow on machines that act as servers for multiple connections. The defaults are 16MB and unlimited respectively.
BTW: 16MB corresponds roughly to 2 mio real numbers, so 1000x2000 matrices is about as big as you can go in versions 0.2 and lower. A work-around is to transmit data per-partes, e.g. by column or row (or use Rserve 0.3 or higher).
Data conversion on-the-fly (at least outgoing) is planned for future releases of Rserve (late 0.3 or 0.4).
|
Which platforms/operating systems are supported by Rserve?
|
|
Rserve should work on any plarform supporting shared libraries which is also supported by R. The following platforms were tested and are known to work with the latest release:
- Linux (PPC, x86)
- Windows (x86)
- Mac OS X / Darwin (PPC, x86)
- AIX (PPC since version 0.1-10)
- SunOS (sun4u since version 0.2)
- HP-UX (HP-9000 since version 0.3-15)
All platforms except Windows support parallel connections and local (unix) sockets.
|
Where are Rcli and C/C++ client sources?
|
|
Rcli C client was removed from recent Rserve sources, because it was compatible only with Rserve version 0.1 and no one seemd to use it anyway (there's a nice direct C API to R). You can still find Rcli.c in the old source releases. It is obsolete by now since the C++ client was released in Rserve version 0.3-14. It can be found in the src/client directory. The C++ client can be compiled without R, just run the configure script in the Rserve directory and make in the src/client directory. There are also two examples supplied - see the ReadMe file supplied with the client (also useful for instructions how to compile it on Windows).
|