Description Usage Arguments Details Value See Also Examples
Methods for coercing "zoo"
objects to other classes and
a generic function as.zoo
for coercing objects to class "zoo"
.
1 |
x |
an object, |
... |
further arguments passed to |
as.zoo
currently has a default method and methods for ts
,
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). Furthermore, fortify.zoo
can transform "zoo"
series to "data.frame"
including the time index and optionally melting a wide series
into a long data frame.
In the conversion between zoo
and ts
, the zooreg
class is
always used.
as.zoo
returns a zoo
object.
zoo
, fortify.zoo
,
zooreg
, ts
, irts
,
tis
, fts
, mcmc
,
xts
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | suppressWarnings(RNGversion("3.5.0"))
set.seed(1)
## 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.