What is Rook?
Rook is a web server interface for R, written by Jeffrey Horner, the author of rApache and brew. But unlike other web frameworks for R, such as brew, R.rsp (which I have used in the past1), Rserve, gWidgetWWWW or sumo (which I haven’t used yet) Rook appears incredible lightweight.
Rook doesn’t need any configuration. It is an R package, which works out of the box with the R HTTP server (R ≥ 2.13.0 required). That means no configuration files are needed. No files have to be placed in particular folders, and I don’t have to worry about access permissions. Instead, I can run web applications on my local desktop.
|Screen shot of a Rook app running in a browser|
Web applications have the big advantage that they run in a browser and hence are somewhat independent of the operating systems and installed software. All I need is R and a web browser. But here is the catch: I have to learn a little bit about the HTTP protocol to develop Rook apps.
Rooks feels like chatting to the HTTP server in its native tongue, while the web frameworks of brew and R.rsp feel more like sending emails in a
knitr/Sweave like format to the server, mixing HTML with R code, to which it replies in pure HTML.
Fortunately Rook comes with some great examples to get you started. You find them in the following folder, after you installed Rook:
Additionally, the slides Building R Web Applications with Rook presented by Jeffrey Horner at the 2012 useR! conference and the talk about Accelerating Model Deployment with Rook given by Jean-Robert Avettand-Fenoel at LondonR in September 2011 provide some great insight and examples.
Using googleVis with Rook
Here is my first Rook app with googleVis, see code below. It displays a little R data frame in a googleVis table by default. The user can change the visualisation by clicking on the Edit me! button and upload her/his own CSV-file, see screen shot above. And as the output of a googleVis function is HTML code already, it is easy to create a web app with it.
Imagine that I would add R code to validate the CSV-file, or even allow Excel-files, or carry out a statistical analysis before I display the data, and suddenly we are talking about a serious web app, with all R code hidden. Even the R-phobics would be happy to use it.
Rook rocks with googleVis!