[R] zoo timeserie continuous? complete with NaN
Gabor Grothendieck
ggrothendieck at gmail.com
Tue Oct 2 17:59:23 CEST 2007
Try this:
> library(zoo)
> dd <- ISOdate(2005, 12, 31, c(12:16,18:23), tz = "")
> z <- zoo(seq_along(dd), dd) # test series
> tt <- seq(time(z)[1], time(z)[length(z)], by = "hour") # hours
> merge(z, zoo(,tt))
2005-12-31 12:00:00 2005-12-31 13:00:00 2005-12-31 14:00:00 2005-12-31 15:00:00
1 2 3 4
2005-12-31 16:00:00 2005-12-31 17:00:00 2005-12-31 18:00:00 2005-12-31 19:00:00
5 NA 6 7
2005-12-31 20:00:00 2005-12-31 21:00:00 2005-12-31 22:00:00 2005-12-31 23:00:00
8 9 10 11
>
On 10/2/07, marcg <mdgi at gmx.ch> wrote:
> dear r-list
>
> I have a zoo object with 2 objects and time:
>
> looks like:
> 2005-12-31 12:00:00 NA NaN
> 2005-12-31 13:00:00 NA NaN
> 2005-12-31 14:00:00 NA NaN
> 2005-12-31 15:00:00 NA NaN
> 2005-12-31 16:00:00 NA NaN
> 2005-12-31 18:00:00 NA NaN
> 2005-12-31 19:00:00 NA NaN
> 2005-12-31 20:00:00 NA NaN
> 2005-12-31 21:00:00 NA NaN
> 2005-12-31 22:00:00 NA NaN
> 2005-12-31 23:00:00 NA NaN
>
> its much longer though...
>
> As you can see, the values for 2005-12-31 17:00:00 miss. How can I let R show me if the timeseries is continuous and if not, to fill up with NaN values (i need a continuous timeseries). is there a function like complete.timeseries(missing=NA)?
>
> Thanks fpr your help
>
> Marc
> --
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list