An Index Class for Testing the Generality of zoo
listindex.Rd"listindex" is a deliberately awkward class, set up only to test
zoo, especially in conversion to C. It is not intended for users.
Details
The "listindex" class does nothing else than wrapping its object
into a list with a single element called index. This assures that
none of the usual methods required by zoo work sensibly out of the box.
Then, the required methods c(), [, length, ORDER,
and MATCH are set up. These simply work by emulating a dispatch on
listindex$index.
Additionally, methods for as.numeric, as.vector, and as.character
are required as well. These are sort of expected by zoo in some places.
Finally, adding print and xtfrm methods helps in other places as well.
Value
Returns structure(list(index = object), class = "listindex"), i.e., a list
of class "listindex" with a single element index containing the
unchanged input object.
Examples
if (FALSE) { # \dontrun{
suppressWarnings(RNGversion("3.5.0"))
set.seed(1)
## two listindex objects wrapping Date vectors
x <- listindex(as.Date(0) + 0:2)
y <- listindex(as.Date(0) + 3:5)
## define zoo objects based on them
z1 <- zoo(rnorm(4), c(x, y[1]))
z2 <- zoo(rnorm(4), c(x[3], y))
## check some simple operations
z1 + z2
lag(z1, -1)
merge(z1, z2)
c(z1[1:2], z2[4])
} # }