(from R-help Digest, Vol 117, Issue 26)
> Date: Sun, 25 Nov 2012 07:49:05 -0800 (PST)
> From: billycorg<candilav at gmail.com>
> To:r-help at r-project.org
> Subject: [R] creation of an high frequency series
> Message-ID:<1353858545067-4650744.post at n4.nabble.com>
> Content-Type: text/plain; charset=us-ascii
>
> Hi R Users!
>
> I would like to create an high frequency series but I am experiencing some
> difficulties.
>
> My series should start at 09.30 a.m. each day and end at 16.00 for,
let's
> say, 2 years. I don't care on how many observations are for each day.
It's
> ok also one observation each minute. In this case, I would have 390
> observations each day.
>
> I have tried the following:
>
> start <- ISOdatetime(year=2001, month=1, day=1, hour=9, min=0, sec=0,
> tz="GMT")
> end <- ISOdatetime(year=2001, month=1, day=1, hour=16, min=0, sec=0,
> tz="GMT")
>
> z <- zooreg(NA, start = start, end = end, frequency=390)
For this problem
z <- zooreg(rep(NA,390), start = start, end = end, frequency=390)
works, however, if your real problem is that you have time stamps,
possibly not equally spaced, then you should consider zoo() with the
order.by argument, for example:
z <- zoo(rep(NA,390), order.by = start + 30 * 0:389)
If your data source actually provides the time stamps then this should
be very easy.
Note that neither of these do consistency checking between the length of
the series and the specified time frame, that is up to you to do. You
might get warning messages later indicating that something is not right
if you made a mistake. Your zooreg() above seems to just ignore the
inconsistency whereas I think zoo() with order.by recycles the data.
Paul
>
> but the result is a poor, single "NA". And I am not considering
multiple
> days..
>
> How could I solve this problem??
>
> Thank you so much!!