I am trying to define an S4 class that contains a ts class object, a
simple 
example is shown in the code below. However, when I try to create a new
object 
of this class the tsp part is ignored, see below. Am I doing something
wrong, 
or is this just a peril of mixing S3 and S4 objects?

> setClass("tsExtended", representation = representation(description 
= "character"), contains = "ts")
[1] "tsExtended"
> new("tsExtended", ts(1:10, frequency = 2), description = "My Time
Series")
Object of class "tsExtended"
Time Series:
Start = 1
End = 10
Frequency = 1
 [1]  1  2  3  4  5  6  7  8  9 10
Slot "description":
[1] "My Time Series"

> # This however seems to work
> tmp <- new("tsExtended", 1:10, description = "My Time Series")
> tsp(tmp) <- c(1, 5.5, 2)
> tmp
Object of class "tsExtended"
Time Series:
Start = c(1, 1)
End = c(5, 2)
Frequency = 2
 [1]  1  2  3  4  5  6  7  8  9 10
Slot "description":
[1] "My Time Series"

Mark Lyman, Statistician
Engineering Systems & Integration, ATK

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to