\Header{tfwindow}{Truncate a Time Series}
\methalias{tfwindow.default}{tfwindow}
\methalias{tfwindow.tframe}{tfwindow}
\methalias{tfwindow.ts}{tfwindow}
\keyword{programming}{tfwindow}
\keyword{utilities}{tfwindow}
\keyword{ts}{tfwindow}
\keyword{chron}{tfwindow}
\begin{Description}\relax
Truncate a time series object to a time window.
\end{Description}
\begin{Usage}
\begin{verbatim}
    tfwindow(x, tf=NULL, start=tfstart(tf), end=tfend(tf), warn=TRUE)
    ## Default S3 method:
    tfwindow(x, tf=NULL, start=tfstart(tf), end=tfend(tf), warn=TRUE)
    ## S3 method for class 'ts':
    tfwindow(x, tf=NULL, start=tfstart(tf), end=tfend(tf), warn=TRUE)
    ## S3 method for class 'tframe':
    tfwindow(x, tf=NULL, start=tfstart(tf), end=tfend(tf), warn=TRUE)
    \end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] A time series object.
\item[\code{start}] A start date of a format compatible with the time series
\item[\code{end}] An end date of a format compatible with the time series
\item[\code{tf}] A tframe or tframed object
\item[\code{warn}] A logical indicating if warning should be produced
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
If \code{start} or \code{end} are omitted and \code{tf} is specified then the
start or end is taken from the \code{tf} object.
For ts class objects this function calls window but makes more effort to 
preserve \code{seriesNames} if \code{x} has them. 
It also supports the optional argument \code{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.
In Splus \code{tfwindow} also corrects for some bugs in older versions 
of code{window}.

The method for windowing a tframe is a utility to be used by other programs and
would not typically be called by a user.\end{Details}
\begin{Value}
A time series object similar to x, but typically spanning a shorter time period.\end{Value}
\begin{Examples}
\begin{ExampleCode}
  z <- ts(matrix(rnorm(24),24,1), start=c(1980,1), frequency=4)
  zz <- tfwindow(z, start=c(1982,2))
  zzz <- matrix(rnorm(24),24,1)
  tframe(zzz) <- tframe(z)
  tfwindow(zzz, tf=tframe(zz))
\end{ExampleCode}
\end{Examples}

