Description Usage Arguments Value See Also Examples
Methods for extracting time windows
of "zoo"
objects and replacing it.
1 2 3 4 |
x |
an object. |
index. |
the index/time window which should be extracted. |
start |
an index/time value. Only the indexes in |
end |
an index/time value. Only the indexes in |
value |
a suitable value object for use with |
... |
currently not used. |
Either the time window of the object is extracted (and hence return a "zoo"
object) or it is replaced.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | suppressWarnings(RNGversion("3.5.0"))
set.seed(1)
## zoo example
x.date <- as.Date(paste(2003, rep(1:4, 4:1), seq(1,19,2), sep = "-"))
x <- zoo(matrix(rnorm(20), ncol = 2), x.date)
x
window(x, start = as.Date("2003-02-01"), end = as.Date("2003-03-01"))
window(x, index = x.date[1:6], start = as.Date("2003-02-01"))
window(x, index = x.date[c(4, 8, 10)])
window(x, index = x.date[c(4, 8, 10)]) <- matrix(1:6, ncol = 2)
x
## for classes that support comparisons with "character" variables
## start and end may be "character".
window(x, start = "2003-02-01")
## zooreg example (with plain numeric index)
z <- zooreg(rnorm(10), start = 2000, freq = 4)
window(z, start = 2001.75)
window(z, start = c(2001, 4))
## replace data at times of d0 which are in dn
d1 <- d0 <- zoo(1:10) + 100
dn <- - head(d0, 4)
window(d1, time(dn)) <- coredata(dn)
## if the underlying time index is a float, note that the index may
## print in the same way but actually be different (e.g., differing
## by 0.1 second in this example)
zp <- zoo(1:4, as.POSIXct("2000-01-01 00:00:00") + c(-3600, 0, 0.1, 3600))
## and then the >= start and <= end may not select all intended
## observations and adding/subtracting some "fuzz" may be needed
window(zp, end = "2000-01-01 00:00:00")
window(zp, end = as.POSIXct("2000-01-01 00:00:00") + 0.5)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.