% File src/library/stats/man/tsp.Rd
% Part of the R package, https://www.R-project.org
% Copyright 1995-2025 R Core Team
% Distributed under GPL 2 or later

\name{tsp}
\title{\code{tsp} Attribute of Time-Series-Like Objects}
\alias{tsp}
\alias{tsp<-}
\alias{hasTsp}
\usage{
tsp(x)
tsp(x) <- value
hasTsp(x)
}
\arguments{
  \item{x}{a vector or matrix or univariate or multivariate time-series.}
  \item{value}{a numeric vector of length 3 or \code{NULL}.}
}
\description{
  \code{tsp} returns the \code{tsp} attribute (or \code{NULL}).
  It is included for compatibility with S version 2. \code{tsp<-}
  sets the \code{tsp} attribute. \code{hasTsp} ensures \code{x} has a
  \code{tsp} attribute, by adding one if needed.
}
\details{
  The \code{tsp} attribute gives the start time \emph{in time units},
  the end time and the frequency (the number of observations per unit of
  time, e.g.\sspace{}12 for a monthly series).
  The frequency may be fractional, see \code{\link{ts}}.

  Assignments are checked for consistency.

  Assigning \code{NULL} which removes the \code{tsp} attribute
  \emph{and} any \code{"ts"} (or \code{"mts"}) class of \code{x}.
}
\value{
  An object which differs from \code{x} only in the \code{tsp} attribute
  (unless \code{NULL} is assigned).

  \code{hasTsp} adds, if needed, an attribute with a start time and
  frequency of 1 and end time \code{\link{NROW}(x)}.
}
\references{
  \bibshow{R:Becker+Chambers+Wilks:1988}
}
\seealso{
  \code{\link{ts}}, \code{\link{time}}, \code{\link{start}}.
}
\keyword{ts}
