how dows this work in R...
I am using a package (zoo 1.6-4) that defines a S3 class for time series sets.
I am writing a derived class where I want to override a few methods and can't get past this one:[.zoo
!
in my derived class rows are indexed by timestamp, like in zoo, but differently from zoo, I allow only POSIXct
values in the index. my users will be selecting columns all of the time, while slicing series only occasionally so I want to offer obj[name]
instead of obj[, name]
.
my objects have class c("delftfews", "zoo")
.
but...
how do I override a method?
I tried this:
"[.delftfews" <- function(x, i, j, drop=TRUE, ...) {
if (missing(i)) return(NextMethod())
if (all(class(i) == "character") && missing(j)) {
return(NextMethod('[', x=x, i=1:NROW(x), j=i, drop=drop, ...))
}
NextMethod()
}
but I get this error: Error in rval[i, j, drop = drop., ...] : incorrect number of dimensions
.
I have solved by editing the source from zoo: I removed those ...
, but I don't get why that works. anybody can explain what is going on here?