FastRWeb: FastRWeb - infratructure to serve web pages with R scripts...

Description Installation Project root anatomy See Also


FastRWeb is not just a package, but an entire infrastructure allowing the use of R scripts to create web pages and graphics.

The basic idea is that an URL of the form http://server/cgi-bin/R/foo?bar=value will be processed by FastRWeb such as to result in sourcing of the foo.R script and running the function run(bar="value") which is expected to be defined in that script. The results of a script can be anything from HTML pages to bitmap graphics or PDF document.

FastRWeb uses CGI or PHP as front-end and Rserve server as the back-end. For details see Urbanek, S. (2008) FastRWeb: Fast Interactive Web Framework for Data Mining Using R, IASC 2008.

The R code in the package itself provides R-side tools that facilitate the delivery of results to a browser - such as WebResult, WebPlot, out, done - more in detail below.


The default configuration of FastRWeb assumes that the project root will be in /var/FastRWeb and that the server is a unix machine. It is possible to install FastRWeb in other settings, but it will require modification of the configuration.

First, the FastRWeb package should be installed (typically using install.packages("FastRWeb") in R). The installed package contains shell script that will setup the environment in /var/FastRWeb. To run the script, use


For the anatomy of the /var/FastRWeb project root see below.

Once created, you can inspect the Rserve configuration file /var/FastRWeb/code/rserve.conf and adjust it for your needs if necessary. You can also look a the Rserve initialization script located in /var/FastRWeb/code/rserve.R which is used to pre-load data, packages etc. into Rserve. If you are happy with it, you can start Rserve using /var/FastRWeb/code/start

In order to tell your webserver to use FastRWeb, you have two options: CGI script or PHP script. The former is more common as it works with any web server. The FastRWeb R package builds and installs the Rcgi script as part of its installation process into the cgi-bin directory of the package, but it has no way of knowing about the location of your server's cgi-bin directory, so it is left to the user to copy the script in the proper location. Use system.file("cgi-bin", package="FastRWeb") in R to locate the package directory - it will contain an executable Rcgi (or Rcgi.exe on Windows) and copy that executable into you server's cgi-bin directory (on Debian/Ubuntu this is typically /usr/lib/cgi-bin, on Mac OS X it is /Library/WebServer/CGI-Executables). Most examples in FastRWeb assume that you have renamed the script to R instead of Rcgi, but you can choose any name.

With Rserve started and the CGI script in place, you should be able to open a browser and run your first script, the URL will probably look something like http://my.server/cgi-bin/R/main. This will invoke the script /var/FastRWeb/web.R/main.R by sourcing it and running the run() function.

For advanced topics, please see Rserve documentation. For production systems we encourage the use of gid, uid, sockmod and umask configuration directives to secure the access to the Rserve according to your web server configuration.

Project root anatomy

The project root (typically var/FastRWeb) contains various directories:

In addition, the default configuration uses a local socket of the name socket to communicate with the Rserve instance. Note that you can use regular unix permissions to limit the access to Rserve this way.

See Also

WebResult, WebPlot, out, done, add.header

FastRWeb documentation built on March 13, 2020, 2:53 a.m.

Related to FastRWeb in FastRWeb...