[Rd] timeSeries and optional S4 slots?

Dominick Samperi djsamperi at gmail.com
Fri May 7 21:59:46 CEST 2010


Question on timeSeries and S4 classes:

Consider the following:
library(timeSeries)
data <- rnorm(5)
treg <- ts(data, frequency=4)

t1 <- timeSeries(data, as.Date('2010-04-15') + 1:5)
t2 <- as.timeSeries(treg)

Now both t1 and t2 are timeSeries objects, yet
t2 at ts is a valid slot, while t1 at ts is not.

Thus the ts slot is optional.

Sorry if I am misunderstanding the way S4 classes
work, but shouldn't a class have a well-defined set of
slots?

It appears that the "constructor" as.timeSeries() used
to create t2 results in a different kind of object from
the one used to define t1, yet the class() operator
returns the same class name ('timeSeries') in both
cases.

Thanks,
Dominick



More information about the R-devel mailing list