Skip to content

AsOf join in R

4 messages · Robert A'gata, Brian G. Peterson, Jeff Ryan +1 more

#
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.
On Wed, Oct 5, 2011 at 9:38 PM, G See <gsee000 at gmail.com> wrote:
#
On Wed, 2011-10-05 at 21:53 -0400, Robert A'gata wrote:
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
#
This is reasonably masochistic, but will do what you want.
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: