[R] Summary: Calendar Time Series

Brian Beckage bbeckage at uvm.edu
Wed Nov 12 15:26:55 CET 2003


Thanks to Patrick Burns, Giles Heywood, and Gabor Grothendiec for 
responding to my question.

Gabor suggested something along the lines of
    z <- ts(rnorm(25),start=as.numeric(chron("01/25/99")))
and then get back the times like this:
    chron(time(z))
To plot it:
    plot(chron(time(z)),z)

Patrick and Giles suggested using the its library.  In case anyone is 
interested, the following code created the time series that I needed:

# Creating dates to associate with the time series
dates.p33<-seq.dates(from="10/01/1952", length=dim(stageP33)[1], by="days");
# The next line insures that the dates start in 1952 rather than 2052
dates.p33<-format(as.POSIXct(dates.p33+1), "%m/%d/%Y")

# Combining dates with data
p33.its<-its(x=as.matrix(stageP33),
 
dates=as.POSIXct(x=strptime(as.character(dates.p33),format="%m/%d/%Y")),
              names=dimnames(stageP33)[[2]],format=its.format())

I don't claim that is the best way to do it.  Also note that this 
required the its and chron libraries.

With regards,
Brian




More information about the R-help mailing list