methods-as: Convert objects to/from class 'timeSeries'

asR Documentation

Convert objects to/from class 'timeSeries'


Functions and methods dealing with the coercion between "timeSeries" and other classes.


## convert to 'timeSeries'
as.timeSeries(x, ...)

## convert from 'timeSeries' to other classes
## S4 method for signature 'timeSeries'
as.matrix(x, ...)
## S4 method for signature 'timeSeries'
as.ts(x, ...)
## S4 method for signature 'timeSeries', row.names = NULL, optional = FALSE, ...)
## S4 method for signature 'timeSeries'
as.list(x, ...)



the object to be converted, see Section ‘Details’ for the special case when class(x) is "character".


NULL or a character vector giving the row names for the data frame. Missing values are not allowed.


a logical value. If TRUE, setting row names and converting column names (to syntactic names) is optional.


arguments passed to other methods.


Functions to create "timeSeries" objects from other objects and to convert "timeSeries" objects to other classes.

as.timeSeries is a generic function to convert an object to "timeSeries". There are specialised methods for the following classes: "ts", "data.frame", "character", and "zoo". The default method is equivalent to calling "timeSeries()", so x can be of any type that "timeSeries()" accepts.

The character method of as.timeSeries is special, in that its contents are parsed and evaluated, then as.timeSeries is called on the returned value (passing also the "..." arguments. Care is needed to avoid infinite recursion here since currently the code doesn't guard against it.


for as.timeSeries, an object of class "timeSeries".

for as.numeric,, as.matrix, as.ts, as.list - a numeric vector, a data frame, a matrix, an object of class ts, or a "list", respectively.

See Also

timeSeries, class timeSeries


## Create an Artificial 'timeSeries' Object
setRmetricsOptions(myFinCenter = "GMT")
charvec <- timeCalendar()
data <- matrix(rnorm(12))
TS <- timeSeries(data, charvec, units = "RAND")

## Coerce to Vector
## Coerce to Matrix
## Coerce to Data Frame

timeSeries documentation built on Aug. 26, 2023, 5:08 p.m.