[R] irregular time series

Nirav Mehta niravmehta.x at gmail.com
Wed Sep 12 17:42:24 CEST 2007


Howdy!

I am attempting to convert a date frame with irregular dates into a
regular time series, aggregated by date. i have tried using both the
'its' and 'zoo' packages.

I have something like

times<-c("2003-03-05", "2003-03-05", "2003-05-05" ,"2003-04-07" ,"2003-03-05")
aarf<-data.frame(times)
aarf$x<-runif(5)

what i want in the end, is a daily time series, aggregating x by day,
and filling in days where there are no data with 0.

I have tried, similarly to another help request, the aggregating once
I have zoo-class data, but my dates disappear, and instead I get
things like 12772 and so on for the various dates. I thought that
these 5-digit numbers were maybe the number of days past Jan 1, 1970,
but dividing these numbers by the number of days in a year gets me out
of my data range.

Also, applying as.ts() to my zoo data gives me a regularly spaced time
series that ignores the timing imposed in zoo.

Similarly, I can convert the series to an 'its' object, but then
cannot convert the 'its' object to a regular time series with 0 filled
in where I have no observations, since the 'its' arithmitic only
returns the intersection of addition of two its vectors.

Thanks,
Nirav Mehta



More information about the R-help mailing list