ts(data = NA, start = <<see below>>, frequency = 1, end = NULL, deltat = 1, names = <<see below>>, ts.eps = .Options$ts.eps) is.ts(x) as.ts(x)
1970+(1/12) or
1970.083. If
start is a vector
with at least two data values, the first is interpreted as
the time unit, e.g., the year, and the second as the number of
positions
into the
sampling period; e.g., February, 1970 could be
c(1970,2).
If both
start and
end are missing, then
start defaults to
1.
frequency=12.
data are used to compute
start.
frequency.
This represents the fraction of the sampling period
between successive observations;
e.g., monthly data has
deltat=1/12. Only one of
frequency or
deltat should be provided.
data is a matrix):
a vector containing character strings to be used as
names for the component series of the multivariate series.
By default, the strings "Series i" i=1,2,...,
ncol(data) are used as
series names (columns of
data) unless
data has an associated
dimnames attribute which is retained by the resulting time series.
The rows of the matrix are also named using
the associated times (from given
start
and
end parameters) for the observations.
.Options$ts.eps=1e-5 which means
that frequencies will be considered equal if they correspond up to their 5th
decimal, if a fraction.
ts returns a time series containing the given
data.
Time series attributes are assigned consistently with whichever of
start
,
end,
frequency
or
deltat are supplied.
If
frequency or
deltat is supplied, then only one of
start or
end
is needed since
the other parameter is computed based on the given values
and
length(data) (or
nrow(data)).
If both
start and
end are omitted, the series is started at 1.
ts
checks that the arguments supplied are consistent.
is.ts returns
TRUE if
x is a time series object (has a
tsp
attribute), and returns
FALSE otherwise.
as.ts returns
x, if
x is a time series, otherwise
ts(x).
Any periodic data can be organized as a time series.
Hourly data might use days for
start and
end with
frequency=24 or
deltat=1/24
;
daily data could use weeks with
frequency=7 or
deltat=1/7.
There is also special printing for
the cases of
frequency=4 or
12 (see
print.ts).
Time series objects are those that have an attribute
tsp,
which must be numeric of length 3.
Multivariate time series objects also have
attributes
dim and (possibly)
dimnames.
Multivariate time series are printed by default like a matrix with the
tsp
attribute printed last.
Calling
print.ts directly provides an alternative.
Time series created by
ts have been superseded by the classed time
series created by
rts,
cts, and
its. You can coerce a old-style
time series to a new with
as.rts.
tsp(freeny.y) # [1] 1962.25 1971.75 4.00 is.ts(freeny.y) # [1] T # Define the matrix of related covariates as a time series and plot ts.freeny.x <- ts(freeny.x, start = 1962.25, frequency = 4) tsplot(ts.freeny.x, freeny.y)