R is a programming language for mathematics and statistics. There are several R libraries available to support web development, including rjson and RJSONIO (note case – R library names are case sensitive). RJSONIO is based on rjson, but with modifications to improve performance working with large JSON payloads.

The example below returns the data required to render a scatter chart with a best fit line like this:

This requires that you’ve already set up rApache. To install RJSONIO, check http://cran.r-project.org/src/contrib/ to find the latest version, and use that filename in the following. It appears that CRAN removes the old versions- unfortunately they don’t have an easy way to just pull the latest.

wget http://cran.r-project.org/src/contrib/RJSONIO_1.0-1.tar.gz R CMD INSTALL RJSONIO_1.0-1.tar.gz

The following code will pull JSON data from the URL, parse it, and return a linear model. This includes information for the graph, error bars, best fit line, axis intercepts, etc. For a charting package like ExtJS, the data may need to be re-formatted to render successfully, which fortunately R is quite good at.