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.
- Take data as given instead of transforming to a cumulative line
- Allow parameters for a title and the location of the x-axis
- 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 Gold and Prices Since 1873 ",
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.