Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Integration with Rserve, a TCP/IP server for R framework

Fetching latest commit…

Cannot retrieve the latest commit at this time



RIO, R Input Output, connects an app to Rserve, a TCP/IP server which allows other programs to use facilities of R.

It supports double, double array, string and string array objects.

It supports also the plain text authentication, if Rserve is configured for that capability.

The main goal is to pass a string containing a script call using a JSON object as parameter. Then, inside the script, using rjsonio package, deserializing the JSON object, calling a method, serializing the response and returning to NodeJS.


var rio = require('rio');

rio.Rserve_eval("pi / 2 * 2");
rio.Rserve_eval('c(1, 2)');
rio.Rserve_eval("as.character('Hello World')");
rio.Rserve_eval('c("a", "b")');
rio.Rserve_eval('Sys.sleep(5); 11')

See examples directory.


To install with npm:

npm install rio

Tested with node 0.4.10 and Rserve 0.6.5 (on Windows 7).

Don't forget to start Rserve. For instance, from R console, after installing the package Rserve:


To shutdown the server from R console:

c <- RSconnect()


  • It works if Rserve runs on a little endian machine.

    return jspack.Unpack(">d", buf, o); // big endian

    return jspack.Unpack("<d", buf, o); // little endian

  • Adding a better error handling if the communication fails.

  • Handling debug ouput

  • If the authentication fails, the callback is not called


Rserve_eval(command, options)

Evaluate a command, connecting to Rserve, executing the command and then disconnecting.

The argument of the callback is false if there is any error.

default options = {
    callback: { sys.puts(res); },
    host = "",
    port = 6311,
    user = "anon",
    password = "anon"
Something went wrong with that request. Please try again.