window {base}R Documentation

Time Windows

Description

window is a generic function which extracts the subset of the object x observed between the times start and end. If a frequency is specified, the series is then re-sampled at the new frequency.

Usage

window(x, ...)
window.default(x, start = NULL, end = NULL,
               frequency = NULL, deltat = NULL)
window.ts(x, start = NULL, end = NULL,
          frequency = NULL, deltat = NULL)

Arguments

x a time-series or other object.
start the start time of the period of interest.
end the end time of the period of interest.
frequency, deltat the new frequency can be specified by either (or both if they are consistent).

Details

The start and end times can be specified as for ts. If there is no observation at the new start or end, the immediately following (start) or preceding (end) observation time is used.

Attempts to extend the series give a warning and are ignored.

Value

The value depends on the method. window.default will return a vector or matrix with an appropriate tsp attribute.

window.ts differs from window.default only in ensuring the result is a ts object.

See Also

time, ts.

Examples

data(presidents)
window(presidents, 1960, c(1969,4)) # values in the 1960's
window(presidents, deltat=1)  # All Qtr1s
window(presidents, start=c(1945,3), deltat=1)  # All Qtr3s

[Package Contents]