Package R docs
|What is Rserve?|
Rserve is a TCP/IP server which allows other programs to use facilities of R (see www.r-project.org) from various languages without the need to initialize R or link against R library. Every connection has a separate workspace and working directory. Client-side implementations are available for popular languages such as C/C++, PHP and Java. Rserve supports remote connection, authentication and file transfer. Typical use is to integrate R backend for computation of statstical models, plots etc. in other applications.
The following Java code illustrates the easy integration of Rserve:
RConnection c = new RConnection();
double d = c.eval("rnorm(10)").asDoubles();
d now contains 10 random samples from the N(0,1) distribution if there is a runing Rserve on the local machine. The RConnection doesn't have to be created more than once for subsequent commands (however, each thread must have its own connection object unless synchronized explicitly).
As a side note - if you are looking just for a way to access R from Java in one application without the need for the client/server concept, you may want to have a look at JRI. It uses JNI to link R directly into Java.
The original Rserve paper is available in the DSC-2003 proceedings. Please cite that paper when using Rserve.
NOTE: Rserve is perfect as a back-end for web services and is often used that way. See also FastRWeb.
Important note about the Java clients: please make sure you're using the REngine-based client! (org.rosuda.REngine.Rserve.RConnection class). For some strange reason some users are still using the old, unsupported JRclient which has been replaced three years ago! On a somewhat related note, if you get the following error: "Rserve exception: Handshake failed: The server uses more recent protocol than this client." then you are using a very old build of the old client! Always take the client supplied with the Rserve version you're using - it's located in src/clients/java-new in the Rserve source package. The old client is still supplied in java-old but its use is strongly discouraged as it's not tested anymore.
|Tell us about your project!|
|Some projects using Rserve:|
If you are using Rserve, please let us know! Please send me an e-mail if your project uses Rserve! Thanks!
| --- The latest Rserve version available from RForge is Rserve_1.7-0 ---|
|2012/12/10||Rserve 1.7-0 is the latest version of Rserve with many new features. Please give it a go - we think it's stable enough. The only reason why it has not been officially released yet is that it currently doesn't support Windows (because many of the new features rely on things lacking in Windows). However, given that it is much more sensible to use unix servers for Rserve deployment (Windows' performance is simply too poor for any server deployment) the majority of users should be able to test the new version and give us feedback.|
|2012/02/20||Rserve 0.6-8 released. Added support for self-control commands as well as RSserverEval(), RSserverSource and control version of RSshutdown.|
|2012/01/22||Rserve 0.6-7 released. This is a security update, if you rely on the built-in authentication, make sure you update at least to this version!|
|2011/12/10||Rserve 0.6-6 released (bugfixes and added support for assigning pure S4 objects)|
|2011/06/21||Rserve 0.6-5 released (Windows-specific updates, use install.libs.R from R 2.13.1 on)|
|2011/05/19||Rserve 0.6-4 released (bugfixes, 64-bit buffer support, changes in Rserve() wrapper)|
|2011/01/17||Rserve 0.6-3 released (added multi-arch support for Windows; update C++ client; one unix bug fix)|
|2010/09/02||Rserve 0.6-2 released (added support for NAs in character vectors; added interactive option - on by default on all platforms; Windows fixes)|
|2010/05/24||Rserve 0.6-1 released (added su and cachepwd config options; added Win64 support; few bugfixes)|
|2009/10/27||Rserve 0.6-0 released (added the concept of control commands aka server-side commands; few bugfixes)|
|2009/01/25||Rserve 0.5-3 released (added string encoding support, allow S3 objects to be synthesized on the client side, added tests, minor fixes)|
|2008/10/17||Rserve 0.5-2 released (fixed bug in readFile and setBufferSize; updated Java client)|
|2008/07/22||Rserve 0.5-1 released (fixes build issues with R 2.7 on Windows and multi-arch install)|
|2008/07/21||Rserve 0.5-0 was released on CRAN. This is a new, major release of Rserve which requires updated client support, because the protocol was substantially changed. It also features a new, efficient R client. Note that the old Java API (JRclient) will no longer be activaley maintained and projects are encouraged to use the new Java API (REngine). This version was in RC stage for quite a long while so hopefully most project switched already. (0.4 versions are still available from RForge for legacy projects, but not from CRAN)|
|2007/03/15||Rserve and its documentation have now officially moved to RForge.|
|2006/11/15||Rserve is now available as a package from CRAN. This also implies that the latest binary versions (both for Windows and Mac OS X) are now available from CRAN. Simply use install.packages("Rserve").|
|2006/05/03||Rserve_0.4-3 released including Windows binary for R 2.3.0. The new 0.4 series supports sessions, i.e. the client can detach from the server and attach to the same session later on (e.g. when the computation has finished). The corresponding new client is now available for download. Also the C++ client has been extended to support authentication and file transfer.|
|2005/01/12||Rserve_0.3-16 released. It allows custom initialization such that you can pre-load data and libraries, allowing even faster responses for specific tasks.|
|2003/10/08||Rserve_0.3-0 and updated Java client released (clients update necessary). Updated FAQ. Updated Windows binary. This version adds support for large data - if you experienced crashes while fetching large data in 0.2 and earlier, use this version instead.|
|Features of Rserve|
- fast - no initialization of R is necessary
- binary transport - the transport protocol sends R objects as binary data, not just R text output.
- automatic type conversion - most R data types are converted into native data types, e.g. the result of rnorm(10) will be double in C/Java. Java client also provides classes for new R types such as RBool, RList etc.
- persistent - each connection has its own namespace and working directory. Every object you create is persistent until the connection is closed. The client doesn't have to fetch or store intermediate results.
- client independence - since the client is not linked to R there are no threading issues like in RSJava etc.
- security - Rserve provides some basic security by supporting encrypted user/password authentication with server challenge. Rserve can be also configured to accept local connections only.
- file transfer - the Rserve protocol allows to transfer files between the client and the server. This way Rserve can be used as a remote server even for task such as generating plot images etc.
- configurable - one configuration file is used to control settings and to enable/disable features such as authorization, remote access or file transfer.
|What Rserve is NOT|
Rserve provides no callback functionality. Your application could implement callbacks via TCP/IP and the R sockets but it is not a part of Rserve.
- Rserve is not a telnet frontend to R. The printed output is not transported (except via capture.output). Rserve uses binary protocol for transport of objects for better speed.
- Rserve is thread safe across connections, but eval methods are not thread safe within one connection. This means that multiple threads should not use the same connection unless they guarantee that no eval calls are run in parallel.
You can read more about the Rserve in the documentation section. Once you read at least the introduction, you can go to the download section to get the necessary files.
Rserve was developed by Simon Urbanek, but anyone interested is welcome to check out the developer section and contribute to the project. The sources are licensed under GPL.