Learn R Programming

tframe (version R2000.6-1)

tfwindow: Truncate a Time Series

Description

Truncate a time series object to a time window.

Usage

tfwindow(x, start.=NULL, end.=NULL, warn=T)

Arguments

x
A time series object.
start.
A start date of a format compatible with the time series
end.
warn
A logical indicating if warning should be produced

Value

  • A time series object similar to x, but typically spanning a shorter time period.

Details

This function calls window but makes more effort to preserve series.names if the x has them. It also supports the optional argument warn to suppress warning messages. Frequently it is convenient to write code which always truncates to a window without first checking if the data is already within the window. Since window produces a warning in this situation, the optional argument is frequently useful when tfwindow is used by other code.

Examples

Run this code
tfwindow(ts(matrix(rnorm(24),24,1), start=c(1980,1), frequency=4), 
	start=c(1982,2))

Run the code above in your browser using DataLab