Old Price Tables in Modern d3 Visualization

April 1, 2013

(This article was first published on Timely Portfolio, and kindly contributed to R-bloggers)

In my post Dust off 130 Year Old Gold Books on Google Bookshelf, I reproduced some of the old and way out of copyright price tables from the appendices in Gold and Prices Since 1873 by James Laurence Laughlin using latticeExtra xyplot. Now, with the clickme multiline d3 ractive built in my last post “Building ractives is so addictive it should be illegal!”, we can easily transform this data into an interactive time series line chart.

I tried to generalize the multiline ractive to create almost any line chart for an xts object from R. See the commit history for the minor modifications that I made to the original ractive:

  1. Take data as given instead of transforming to a cumulative line
  2. Allow parameters for a title and the location of the x-axis
  3. Handle data series with differing start and end dates

We can build the html file using clickme with a couple of lines of R code.

# if not already installed, uncomment the two lines below
# library(devtools) install_github('clickme', 'nachocab')

# set location where you put your multiline ractive
set_root_path("path to your ractive/r")
clickme(data = priceTables["1850::", c(-1, -6, -8, -11, -12)], ractive = "clickme_multiline_generic", 
params = list(title = "Price Tables from <em> Gold and Prices Since 1873 </em>",
x_axis_location = 100))

I had not seen an example of passing parameters, so I used title and x_axis_location as a test for how clickme handles parameters. If I read the source correctly, the template_config.yml specifies permissible parameters. Then the parameters can be specified by a list provided as params to the clickme function as shown above.

default_parameters: {
width: 960,
height: 500,

Live example

Git Repo

To leave a comment for the author, please follow the link and comment on their blog: Timely Portfolio.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training





CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)