as {timeSeries}R Documentation

Convert objects to/from class 'timeSeries'

Description

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

Usage

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

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

Arguments

x

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

row.names

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

optional

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

...

arguments passed to other methods.

Details

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.

Value

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

for as.numeric, as.data.frame, 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

Examples

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

## Coerce to Vector
as.vector(TS)
   
## Coerce to Matrix
as.matrix(TS)
  
## Coerce to Data Frame
as.data.frame(TS)

[Package timeSeries version 4032.109 Index]