\Header{tframe}{Extract or Set a tframe}
\alias{is.tframe}{tframe}
\alias{is.tframed}{tframe}
\methalias{tframe.default}{tframe}
\methalias{tframe.ts}{tframe}
\alias{tframe<\Rdash}{tframe}
\methalias{tframe<\Rdash.cts}{tframe}
\methalias{tframe<\Rdash.default}{tframe}
\methalias{tframe<\Rdash.its}{tframe}
\methalias{tframe<\Rdash.rts}{tframe}
\methalias{tframe<\Rdash.ts}{tframe}
\alias{tframed}{tframe}
\methalias{tframed.default}{tframe}
\keyword{programming}{tframe}
\keyword{utilities}{tframe}
\keyword{ts}{tframe}
\keyword{chron}{tframe}
\begin{Description}\relax
Extract or set the tframe of an object.
\end{Description}
\begin{Usage}
\begin{verbatim}
    tframe(x)
    ## Default S3 method:
    tframe(x)
    ## S3 method for class 'ts':
    tframe(x)

    tframe(x) <- value
    ## Default S3 method:
    tframe(x) <- value
    ## S3 method for class 'rts':
    tframe(x) <- value
    ## S3 method for class 'cts':
    tframe(x) <- value
    ## S3 method for class 'its':
    tframe(x) <- value
    ## S3 method for class 'ts':
    tframe(x) <- value

    tframed(x, tf=NULL, names = NULL)
    ## Default S3 method:
    tframed(x, tf = NULL, names = NULL)

    is.tframe(x)
    is.tframed(x)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x}] an object (to which a tframe is assigned in assignment methods).
\item[\code{value}] a tframe.
\item[\code{tf}] a tframe object or a tframed object from which a tframe is taken.
\item[\code{names}] optional vector of strings to specify new series names.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The first usage returns the tframe of a tframed object. The assignment
methods and tframed set the tframe of an object. \code{is.tframe} returns 
a logical.

The pure tframe approach is to set a "tframe" attribute for an object. This
attribute has a class which indicates the time framing which is used. The 
the time frame information is often secondary, in the sense that it does not
describe the object structure, but only provides some additional information
which is useful for doing time based operations on the data, plotting, and
printing the object. By putting this in 
an attribute, the objects class can be used for indicating other
information about the structure of the object.  For
these pure tframe objects the default \code{tframe} and code{tframe<-} will
often be adequate. The generic/method approach allows for special case (like
TSdata where the tframe information is not an attribute of the object, but
rather an attribute of the data matrices which are elements of the object).

The generic/method approach also allows for (faking) tframe assignment and 
extraction with classes like rts, ctc, its, ts, and others which may appear,
that try to make the time description part of the object class. (Not 
a "tframe" approach.) The problem is to extract real tframes and
also fake these other classes and old style tsp objects so they look 
like tfamed objects. Another approach would be to mutilate these objects 
and force them really be tframed objects (to have a tframe attribute), 
but that risks conflicting with other (non tframe) code which used 
the objects. This faking is accomplished by specific methods of the classes,
and for old style tsp objects it is built into the default.

This \code{tframed} constructor is simply a shortcut for assigning the tframe
(tframe(x) <- tf) and series names (seriesNames(x) <-  names) to an object,
but never assigns NULL values, so the result is guaranteed to be a 
code{tframed} object. It is like \code{ts} but enables the tframe library's  
methods for handling time. If the \code{tf} argument is a 
\code{tframed} object rather than a \code{tframe}, then the code{tframe} 
is extracted and used. If the \code{names} argument is not mode "character"
of appropriate length, then \code{seriesNames(names)} is used. These make it
simple to assign the time frame and names of one object to another by
\code{z <- tframed(x, tf=y, names=y)}.

\code{is.tframed} returns TRUE if a
\code{tframe()} can extract a tframe from the object. This is true for many
objects which are not truly tframed (like ts objects), since \code{tframe()}
tries fairly hard to build a tframe for the object.\end{Details}
\begin{Value}
Depends.\end{Value}
\begin{SeeAlso}\relax
\code{\Link{tfstart}},
\code{\Link{tfend}},
\code{\Link{tffrequency}},
\code{\Link{tfperiods}},
\code{\Link{tftime}},
\code{\Link{tfdiff}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
    z <- tframe(ts(rnorm(100), start=c(1982,1), frequency=12))
    is.tframe(z)
    zz <- tframed(matrix(rnorm(200), 100,2), tf=z)
    is.tframed(zz)
    zzz <- tframed(matrix(rnorm(200), 100,2), tf=zz)
    is.tframed(zzz)
    tframe(zzz)
\end{ExampleCode}
\end{Examples}

