FastRWeb - Fast Interactive Web Framework for Data Mining Using R
RForge.net

FastRWeb

About FastRWeb
SVN access
Download/Files
News
Check results
Package R docs

What is FastRWeb?
        

FastRWeb is an infrastructure that allows any webserver to use R scripts for generating content on the fly, such as web pages or graphics. URLs are mapped to scripts and can have optional arguments that are passed to the R function run from the script. For example http://my.server/cgi-bin/R/foo.png?n=100 would cause FastRWeb to look up a script foo.png.R, source it and call run(n="100"). So for example the script could be as simple as

run <- function(n=10, ...) {
   p <- WebPlot(800, 600)
   n <- as.integer(n)
   plot(rnorm(n), rnorm(n), col=2, pch=19)
   p
}
and thus the above URL would show a plot.

FastRWeb can be run on any webserver that supports either CGI or PHP. As of version 1.1 it can be also used directly with the built-in webserver in Rserve 1.7 and higher. It uses Rserve as a back-end which allows very fast responses as there is no need to start R for each request. Also Rserve and allows to pre-load data and packages into the server which is important for live monitoring and reporting. This allows FastRWeb scripts to be used for time-sensitive tasks like tooltips or live search as you type.

The original FastRWeb paper was presented at IASC 2008 and is available here as PDF.

Please read the INSTALL file in the package for installation instructions!

What's new?
    --- The latest FastRWeb version available from RForge is FastRWeb_ ---
2012/12/15FastRWeb 1.1-0 was released on CRAN. This is a major release.
IMPORTANT: Please make sure you read the NEWS file before upgrading. FastRWeb 1.0 provided several undocumented variables in the workspace to pass additional information. Those have been replaced by the request variable. In addition paremeters were URL-encoded in FastRWeb 1.0 which was a bug, all parameters are now correctly decoded so you may need to change your code if you were decoding them. You can check for the webapi variable which is now present in FastRWeb 1.1 and later defining the API version. The new version was around as beta for many months so this should not be a big surprise.
Also please do not forget to update the R binary in cgi-bin (when using CGI) or the PHP script - it must match the version of the FastRWeb package installed.
2012/02/10The development version of FastRWeb 1.1-0 supports request bodies (useful for POST requests) and adds a new, simplified API for the R code. Please give it a spin and report any issues or suggestions to me before it will go on CRAN. See the NEWS for details.
2011/12/10FastRWeb 1.0-1 released. S3 method registration bugfix and added rudimentary form elements constructors oinput(), oselection() and osubmit().
2011/10/07FastRWeb 1.0-0 released on CRAN. It includes sample server configuration forunix servers.
2008/12/06FastRWeb 0.1-0 released - added WebResult and WebPlot classes for automated result conversion
2008/10/13FastRWeb is released to the public on RForge.net.
Documentation
First, please consider reading the IASC paper - it is not long and covers the basics.

FastRWeb consists of several parts:

  • Webserver-to-R pipeline, consisting of either a thin CGI or a PHP client connecting to Rserve which sources and runs the R script. The CGI client is called Rcgi and is compiled as part of the package. The PHP client is part of Rserve in the clients section.
  • FastRWeb R package providing supporting functions such as WebPlot, otable, done that simplify the writing of scripts producing HTML output and graphics. Strictly speaking this part is optional. It is documented in the FastRWeb package documentation.
  • Optional HTML and JavaScript tools for common tasks like AJAX and mouse-over queries. For complex projects it is beneficial to use AJAX to load various parts of a page instead of embedding everything into one HTML document. This makes it much easier to develop since content is modularized into multiple scripts. This is intended for more advanced users. This isinstalled in the web directory - see below.

Jay Emerson has a nice blog entry about his experience with setting up FastRWeb on Ubuntu. Also please read the INSTALL file in the package.

For unix systems, FastRWeb privides a sample script install.sh that sets up the environment -- you can run it somewhat like this:

cd `echo 'cat(system.file(package="FastRWeb"))' | R --slave`
sh install.sh

Have a look at the script - it sets up a root /var/FastRWeb with the following subdirectories:

  • code - this directory contains supporting scripts that involved configuring Rserve, starting it etc. See README in this directory for details
  • web.R - this is the main directory containing R scripts that will be run by the webserver. All URLs will be mapped here by appending .R to the file name.
  • web - this is an optional directory for static web content that an be server through R.
  • tmp - this is a temporary directory used to store intermediate files such as plots before they are served and it serves as the working directory for the scripts.

 
What about Windows? You can run FastRWeb on Windows if you want - it uses local TCP/IP to communicate with Rserve (since Windows does not support unix sockets). However, I would strongly advise against running any server involving R on Windows due to lack of capabilities in the Windows operating system which prevents spawning of parallel R connections. If desired, FastRWeb can split front-end and backend so you can easily run Rserve on unix and use Windows web server (if you really have to) and thus avoid some of the main performance and scalability issues casued by the Windows operating system.