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)
cycle(x)

REQUIRED ARGUMENTS:
x:
univariate or multivariate time series. Missing values (NAs) are allowed.

VALUE:
The time function returns the time value of each observation. For instance, time(x)[1] is the same as start(x), the starting time of x, and time(x)[length(time(x))] is the same as end(x), the ending time of x. If x is a regular time series (of class "rts"), time returns a univariate time series with the same time parameters (tspar) and ending time as x; if x is a calendar time series, time returns a vector of dates, and if x is an irregular time series, time returns the same vector as tspar.

The cycle function returns the position of each observation within the cycle of length frequency associated with the series. If x were monthly, this would be the month number: 1 for each January, etc.


DETAILS:
These are generic functions with methods for each time series class.

Neither time.its nor time.cts return a time series since they may return a vector of class dates which is not an acceptable time series in the current implementation.

The method cycle.cts implicitly assumes a yearly cycle with one exception: If units="days" and frequency=7 then it uses days of the week to decide where the cycle begins (thereby implicitly assuming a weekly cycle).

The cycle function is not defined for irregular time series.


SEE ALSO:
aggregate , cts , cycle , factor , its , rts , start , tapply , tspar .

EXAMPLES:
growth <- rts(sample(100:300,25), freq = 12, units = "months")
fgrowth <- factor(cycle(growth), levels = 1:12, labels = month.name)
tapply(growth, fgrowth, mean)   # mean growth for each month

x <- rts(rnorm(100), start = c(1953, 4), frequency = 12) plot(time(x), x) # similar to ts.plot(x)