window is a generic function which
extracts the subset of the object
observed between the times
end. If a
frequency is specified, the series is then re-sampled at the new
window(x, ...) ## S3 method for class 'ts' window(x, ...) ## Default S3 method: window(x, start = NULL, end = NULL, frequency = NULL, deltat = NULL, extend = FALSE, ts.eps = getOption("ts.eps"), ...) window(x, ...) <- value ## S3 replacement method for class 'ts' window(x, start, end, frequency, deltat, ...) <- value
a time-series (or other object if not replacing values).
the start time of the period of interest.
the end time of the period of interest.
the new frequency can be specified by either (or both if they are consistent).
logical. If true, the
time series comparison tolerance. Frequencies are
considered equal if their absolute difference is less than
further arguments passed to or from other methods.
The start and end times can be specified as for
there is no observation at the new
the immediately following (
start) or preceding (
observation time is used.
The replacement function has a method for
ts objects, and
is allowed to extend the series (with a warning). There is no default
The value depends on the method.
window.default will return a
vector or matrix with an appropriate
window.ts differs from
window.default only in
ensuring the result is a
extend = TRUE the series will be padded with
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.
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 window(presidents, 1944, c(1979,2), extend = TRUE) pres <- window(presidents, 1945, c(1949,4)) # values in the 1940's window(pres, 1945.25, 1945.50) <- c(60, 70) window(pres, 1944, 1944.75) <- 0 # will generate a warning window(pres, c(1945,4), c(1949,4), frequency = 1) <- 85:89 pres
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.