R-listers: I may be asking too much from R, but is there a way to use time indexing on a time series object. For instance:> tsobject <- ts(1:12, start =1999, freq = 4) > tsobjectQtr1 Qtr2 Qtr3 Qtr4 1999 1 2 3 4 2000 5 6 7 8 2001 9 10 11 12> tsobject[1999,Qtr4]Error in NextMethod("[") : Object "Qtr4" not found I would like tsobject[1999,Qtr4] (or something close to that) to return 4, not the error. Any suggestions? Thanks, Jason Higbee Research Analyst Federal Reserve Bank of St. Louis [[alternative HTML version deleted]]
Jason.L.Higbee at stls.frb.org wrote:> R-listers: > > I may be asking too much from R, but is there a way to use time indexing > on a time series object. For instance: > > >>tsobject <- ts(1:12, start =1999, freq = 4) >>tsobject > > Qtr1 Qtr2 Qtr3 Qtr4 > 1999 1 2 3 4 > 2000 5 6 7 8 > 2001 9 10 11 12 > >>tsobject[1999,Qtr4] >Qtr4 isn't a part of the tsobject. It's produced by the print method for ts objects in general. I believe you want "window" Something like... > window(tsobject, start=c(1999,4), deltat =1) Time Series: Start = 1999.8 End = 2001.8 Frequency = 1 [1] 4 8 12 Cheers Jason -- Indigo Industrial Controls Ltd. http://www.indigoindustrial.co.nz 64-21-343-545 jasont at indigoindustrial.co.nz