time
Create Time Vector or Index of Frequency

Description

Returns a univariate time series or other object giving either the time point or the position in a cycle of a time series.

Usage

time(x, ...)
## Default S3 method:
time(x, offset = 0, ...) 
cycle(x, ...)
## Default S3 method:
cycle(x, ...) 

Arguments

x A time series object or something like a vector or matrix that as.ts() can convert to a time series.
offset A number to add to the usual output. It is interpreted as a fraction of deltat(x).
... other arguments passed to or from methods or future functions.
Value
For x of class ts, both time(x) and cycle(x) return a univariate time series: If x is not a time series object, then it is converted to one with as.ts(x) and treated as described above.
See Also
as.ts ts, tsp.
Examples
# Earnings/share of hypothetical public company
eps <- ts(c(2.43, 2.67, 2.50, 2.44,  2.47, 2.73, 2.55, 2.49, 2.55, 2.79),
          frequency=4, start=2010.25)
time(eps)
# fiscal year starts Dec. 1, 2/3 of way through a calendar quarter,
# so use the offset argument:
time(eps, offset=2/3)
cycle(eps)
tapply(eps, cycle(eps), median) # median earnings by quarter
Package stats version 6.1.1-7
Package Index