From djsamperi at gmail.com  Fri May  7 21:59:46 2010
From: djsamperi at gmail.com (Dominick Samperi)
Date: Fri, 7 May 2010 15:59:46 -0400
Subject: [Rd] timeSeries and optional S4 slots?
Message-ID: <j2pd4cf43b61005071259tb51c8fd8wc98423d148542092@mail.gmail.com>

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



[Rd] timeSeries and optional S4 slots?
Dominick Samperi