Skip to content
Prev 30787 / 398530 Next

Subsetting Time Series

Martin Maechler wrote:

            
There does seem to be a problem in 1.6.2 - or am I missing something? 
First, x is a ts object. Once I use subsetting notation to replace one 
value, x does not seem to print correctly, and is.ts reports FALSE:

 > x <- ts(1:12,start=c(2003,1),frequency=12)
 > x
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2003   1   2   3   4   5   6   7   8   9  10  11  12
 > x[1]
[1] 1
 > x[1] <- 9
 > x
 [1]  9  2  3  4  5  6  7  8  9 10 11 12
attr(,"tsp")
[1] 2003.000 2003.917   12.000
attr(,"class")
[1] "ts"
 > x
 [1]  9  2  3  4  5  6  7  8  9 10 11 12
attr(,"tsp")
[1] 2003.000 2003.917   12.000
attr(,"class")
[1] "ts"
 > as.ts(x)
     Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
2003   9   2   3   4   5   6   7   8   9  10  11  12
 > is.ts(x)
[1] FALSE

Is it supposed to work this way?

Rick B.