[R-SIG-Finance] AsOf join in R

Jeffrey Ryan jeffrey.ryan at lemnica.com
Thu Oct 6 04:26:52 CEST 2011


This is reasonably masochistic, but will do what you want.

> merge(A,align.time(B),fill=na.locf)[index(A)]
            A align.time.B.
2011-09-01 10           1.1
2011-09-09 15           1.1
2011-09-10 20           1.5
2011-09-15 25           1.7

In effect you are perturbing the time on B by some increment (default
here is 1s), filling the NAs with na.locf, and then only taking the
rows that match the first index.

That said, I am not sure what you are doing makes sense to me either though.

Jeff

On Wed, Oct 5, 2011 at 9:08 PM, Brian G. Peterson <brian at braverock.com> wrote:
> On Wed, 2011-10-05 at 21:53 -0400, Robert A'gata wrote:
>> Hi Garrett - Yes. I'm very sure. This type of operation occurs a lot
>> when manipulating high-frequency financial data. I think what RTAQ
>> offers is good. I can use that as a template to start with. Thank you.
>
> We all deal with high frequency data professionally, and cbind/na.locf
> is the most common way of getting what we want:  the prevailing bid/ask
> at the time of a trade.  So, either your data is very different from
> every other tick data I have ever seen, or you should consider that you
> may be doing something wrong.
>
> If you're convinced you know what you're doing, Gabor's advice will
> work.
>
> Cheers,
>
>   - Brian
>
> _______________________________________________
> R-SIG-Finance at r-project.org 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
jeffrey.ryan at lemnica.com

www.lemnica.com
www.esotericR.com



More information about the R-SIG-Finance mailing list