Yes, Achim is spot on.

> ge
                    [,1]
2010-01-04 09:30:00    1
2010-01-04 09:31:00    2
2010-01-04 09:34:00    3
2010-01-04 09:35:00    4
> msft
                    [,1]
2010-01-04 09:30:00    1
2010-01-04 09:32:00    2
2010-01-04 09:33:00    3


> merge(ge,msft,xts(,timeBasedSeq("20100104 09:30/20100104 09:35")),
fill=na.locf)
                    ge msft
2010-01-04 09:30:00  1    1
2010-01-04 09:31:00  2    1
2010-01-04 09:32:00  2    2
2010-01-04 09:33:00  2    3
2010-01-04 09:34:00  3    3
2010-01-04 09:35:00  4    3

Other tools that could be used to aggregate to coarser times (if you had
subseconds say) are to.period and align.time:

> (x <- xts(1:5, Sys.time() + sample(seq(1, 300, 10), 5)))
                    [,1]
2010-06-21 20:25:32    4
2010-06-21 20:26:52    3
2010-06-21 20:27:52    5
2010-06-21 20:29:12    2
2010-06-21 20:30:22    1
> align.time(x, 60)
                    [,1]
2010-06-21 20:26:00    4
2010-06-21 20:27:00    3
2010-06-21 20:28:00    5
2010-06-21 20:30:00    2
2010-06-21 20:31:00    1
> align.time(x, 60*2)
                    [,1]
2010-06-21 20:26:00    4
2010-06-21 20:28:00    3
2010-06-21 20:28:00    5
2010-06-21 20:30:00    2
2010-06-21 20:32:00    1

HTH
Jeff

On Mon, Jun 21, 2010 at 8:17 PM, Dirk Eddelbuettel <[email protected]> wrote:

>
> On 22 June 2010 at 02:50, Achim Zeileis wrote:
> | On Mon, 21 Jun 2010, Eric Zivot wrote:
> |
> | > I am trying to align an xts object containing irregularly spaced
> intra-day
> | > price data to a regularly spaced time clock so that I can do realized
> | > variance/covariance calculations. For example, I have two xts objects
> | > msftTrades and geTrades created by the RTAQ package (the time index
> variable
> | > is a timeDate object) :
> |
> | I suspect that xts has some high-level tools that could be leveraged for
> | this.
>
> Yup, I reckon that   help(to.period)   would be what Eric is looking for.
>
> --
>  Regards, Dirk
>
> _______________________________________________
> [email protected] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.
>



-- 
Jeffrey Ryan
[email protected]

ia: insight algorithmics
www.insightalgo.com

        [[alternative HTML version deleted]]

_______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should 
go.

Reply via email to