as.zoo {zoo}R Documentation

Coercion from and to zoo

Description

Methods for coercing "zoo" objects to other classes and a generic function as.zoo for coercing objects to class "zoo".

Usage

as.zoo(x, ...)

Arguments

x

an object,

...

further arguments passed to zoo when the return object is created.

Details

as.zoo currently has a default method and methods for ts, its, fts, irts, mcmc, tis, xts objects (and zoo objects themselves).

Methods for coercing objects of class "zoo" to other classes currently include: as.ts, as.matrix, as.vector, as.data.frame, as.list (the latter also being available for "ts" objects).

In the conversion between zoo and ts, the zooreg class is always used.

Value

as.zoo returns a zoo object.

See Also

zoo, zooreg, ts, its, irts, tis, fts, mcmc, xts.

Examples

## coercion to zoo:
## default method
as.zoo(rnorm(5))
## method for "ts" objects
as.zoo(ts(rnorm(5), start = 1981, freq = 12))

## coercion from zoo:
x.date <- as.POSIXct(paste("2003-", rep(1:4, 4:1), "-", sample(1:28, 10, replace = TRUE), sep = ""))
x <- zoo(matrix(rnorm(24), ncol = 2), x.date)
as.matrix(x)
as.vector(x)
as.data.frame(x)
as.list(x)

[Package zoo version 1.7-7 Index]