# zoo Reference Card

## Creation

- zoo(x, order.by): Creation of a `"zoo"` object from the observations `x` (a vector or a matrix) and an index `order.by` by which the observations are ordered.

  For computations on arbitrary index classes, methods to the following generic functions are assumed to work: combining `c()`, querying length `length()`, subsetting `[`, ordering `ORDER()` and value matching `MATCH()`. For pretty printing an `as.character` and/or `index2char` method might be helpful.

## Creation of regular series

- zoo(x, order.by, freq): Works as above but creates a `"zooreg"` object which inherits from `"zoo"` if the frequency `freq` complies with the index `order.by`. An `as.numeric` method has to be available for the index class.
- zooreg(x, start, end, freq): Creates a `"zooreg"` series with a numeric index as above and has (almost) the same interface as `ts()`. |

## Standard methods

- plot: Plotting. Alternatives: xyplot (`lattice`), autoplot (`ggplot2`), tinyplot.
- lines: Adding a `"zoo"` series to a plot.
- print: Printing.
- summary: Summarizing (column-wise).
- str: Displaying structure of `"zoo"` objects.
- head, tail: Head and tail of `"zoo"` objects.

## Import/export

- read.zoo: Reads `"zoo"` objects from text files, e.g., in CSV format (comma-separated values).
- write.zoo: Writes `"zoo"` objects to text files such, e.g., in CSV format.

## Coercion

- as.zoo: Coercion to `"zoo"` is available for objects of class `"ts"`, `"xts"`, `"timeSeries"`, and many others.
- as.class.zoo: Coercion from `"zoo"` to other classes. Includes methods for class in `"matrix"`, `"vector"`, `"data.frame"`, `"list"`, `"ts"`, `"xts"`, `"timeSeries"`, and several others.
- is.zoo: Querying wether an object is of class `"zoo"`.

## Merging and binding

- merge: Union, intersection, left join, right join along indexes.
- cbind: Column binding along the intersection of the index.
- c, rbind: Combining/row binding (indexes may not overlap).
- aggregate: Compute summary statistics along a coarser grid of indexes

## Mathematical operations

- Ops: Group generic functions performed along the intersection of indexes.
- t: Transposing (coerces to `"matrix"` before).
- cumsum: Compute (columnwise) cumulative quantities: sums `cumsum()`, products `cumprod()`, maximum `cummax()`, minimum `cummin()`.

## Extracting and replacing data and index

- index, time: Extract the index of a series.
- index<-, time<-: Replace the index of a series.
- coredata, coredata<-: Extract and replace the data associated with a `"zoo"` object.
- lag: Lagged observations.
- diff: Arithmetic and geometric differences.
- start, end: Querying start and end of a series.
- window, window<-: Subsetting of `"zoo"` objects using their index.

## `NA` handling

- na.omit: Omit `NA`s.
- na.contiguous: Compute longest sequence of non-`NA` observations.
- na.fill: Impute `NA`s by filling gaps with specific values.
- na.locf: Impute `NA`s by carrying forward the last observation.
- na.approx, na.spline: Impute `NA`s by interpolation.
- na.trim: Remove leading and/or trailing `NA`s.

## Rolling analytics

- rollapply: Apply a function to rolling margin of an array.
- rollmean: More efficient functions for computing the rolling mean, median and maximum are `rollmean()`, `rollmedian()` and `rollmax()`, respectively.

## Methods for regular series

- is.regular: Checks whether a series is weakly (or strictly if `strict = TRUE`) regular.
- frequency, deltat: Extracts the frequency or its reciprocal value respectively from a series, for `"zoo"` series the functions try to determine the regularity and frequency in a data-driven way.
- cycle: Gives the position in the cycle of a regular series.

## Time classes for monthly and quarterly data

- yearmon: Time index class for monthly data.
- yearqtr: Time index class for quarterly data.