liebke/incanter — pull request #62 by ejackson (2012-02-12 18:14:22+00:00)
Title: First draft of zoo functionality.

This request contains the basis for a timeseries datatype utilising the incanter.core.Dataset type as its core type. This is intended as a first draft to demonstrate the idea and provide a basis for discussion and improvement.

The functionality included is:
* Core
** zoo : This constructs a zoo type from a Dataset. It is passed a column to treat as the time index, coerces all values in column to date-time, renames the column to :index and orders the Dataset by :index.
** $$ : This time slices the zoo. It accepts as time arguments anything that can be coerced to date-time. It accepts either one or two time arguments, outputting either a single row or all rows within the interval formed by the arguments, respectively.

* Utilities
** lag : lags a timeseries by a number of units of the frequency of the series. Maintain the total length of the series by inserting rows, where each column contains nils, at the top to compensate.
** aligned? : predicate to indicate whether the timeseries passed in have exactly the same :index columns.
** within-zoo? : predicate to indicate whether the passed in value, which must be coercible to date-time, falls within the interval spanned by the zoo. Does not need to be an existing index.
** coredata: Return the :rows, with :index dissoc'd. Mainly used internally, but useful enough to expose.

* Mapping functions
** zoo-apply : applies a function to a column of a zoo, returning a zoo of the same length containing only :index and the selected column. Unlike transform-col in incancer-core, which is similar, this does not operate element-wise down the column passes the entire column to roll-apply.
** zoo-row-map : maps a function row-wise over any number of zoos.

Questions:
* It may be sensible to revisit the core datatype to achieve performance. Initially it is useful to be based on Dataset so as to integrate with the rest of Incanter.
* The *-apply and *-map functions are probably misnamed. This matches R's naming convention for such functions, but clashes with Clojure's which we should respect.