We have discussed the use of R as a tool for generating web pages but have glossed over the details as to how this occurs. For a web browser to be able to communicate to a web 8 1 Introduction service that exposes functionality provided by R, it needs to communicate over a protocol. A protocol is simply a standard set of rules that a web browser and a web server can use to send messages between each other, much like humans use a language to send messages to one another. There are two protocols of interest that are used to construct web pages, HTTP and WebSockets.
HTTP operates in a request-response model. This means that a web browser sends a message to a web server that requests a resource (e.g. a web page or an image). The web server responds with a message containing the resource that the web browser requested, that the browser can then render. The majority of the software packages that provide a web interface to R operate using HTTP.
WebSockets is a protocol which allows for bi-directional communication between a WebSocket server and a web browser. Instead of requesting a resource, a web browser sends a message over the WebSocket which is received by the WebSocket server. The server needs to know how to read the message, and it also needs to know what task the message is asking to be performed. If both of these requirements are fulfilled, then the WebSocket server can send a message along the socket to the web browser. The message could (for example) include new content that should be included in a web page.
A potentially useful feature of WebSockets is that the server can also send a message to the browser without the browser having to explicitly request it. An example of this is when the server sends the browser the current time every minute. All the browser needs to do in this instance is to know what to do with the current time information.
The key difference between the two protocols is that HTTP requires the browser to request a resource, while WebSockets is simply a means to send a message without any explicit action being applied. In other words, HTTP is analogous to sending messages in the mail whereas WebSockets is analogous to communicating via telephone.
There are several options available to us for enabling R to act as a web server. Some of these options directly expose the HTTP or WebSockets protocol from R, while others allow this to occur indirectly by acting as an intermediary between R and a web browser. We will begin by listing the possible options for generating R content for use within a web browser.
Rserve The Rserve package (Urbanek, 2003) allows R to act as a background service (potentially on a remote machine) that is able to respond to requests over the TCP/IP protocols. This means that it is not directly able to be used by a web
1.1 What are these Graphics?
1.2 Existing Software
2 Generating Unique Names
2.1 Name Translation .
2.3 Name Sharing
2.5 Controlling Output
3 Structured SVG Generation
3.1 The Previous Approach
3.2 Structured Output with the XML package
4 The gridSVG Coordinate System
4.2 The gridSVG Coordinate System
4.3 Browser-based Modification
4.4 Modification via the XML Package
5 The selectr Package
6 Animation Sequencing
7 Advanced SVG Features
GET THE COMPLETE PROJECT
Dynamic, Interactive and Reactive Statistical Graphics for the Web