Learn R Programming

timeSeries (version 4041.111)

time: Get and set time stamps of a 'timeSeries'

Description

Functions and methods extracting and modifying positions of 'timeSeries' objects.

Usage

# S4 method for timeSeries
time(x, ...)
# S3 method for timeSeries
time(x) <- value

getTime(x) setTime(x) <- value

Value

for time and getTime, a "timeDate" object,

for time<- and and setTime, the modified

"timeSeries" object.

Arguments

value

a valid value for the time component of x.

x

an object of class timeSeries.

...

optional arguments passed to other methods.

Details

time and time<- are generic functions with methods for class "timeSeries". They get and set the time component of the object.

getTime and setTime are non-generic alternatives are non-generic wrappers of time and time<-, respectively.

There is another generic function time<- defined in package zoo. When that package is loaded its time<- gets the "timeSeries" method. Also, if "time<-" is called with an object from class other than "timeSeries", the call is dispatched to "zoo:time<-" to apply a suitable method.

Examples

Run this code
## Create Dummy 'timeSeries' -      
   X <- timeSeries(matrix(rnorm(24), 12), timeCalendar())
   
## Return Series Positions -
   getTime(X)
   time(X)  
  
## Add / Subtract one Day from X
   setTime(X) <- time(X) - 24*3600 # sec
   X
   time(X) <- time(X) + 24*3600 # sec
   X

Run the code above in your browser using DataLab