[R-SIG-Finance] AsOf join in R
Gabor Grothendieck
ggrothendieck at gmail.com
Thu Oct 6 03:46:01 CEST 2011
On Wed, Oct 5, 2011 at 9:11 PM, Robert A'gata <rhelpacc at gmail.com> wrote:
> Hi Brian,
>
> Thanks for getting back. I'm afraid it's not doing what I intend. If
> you see value of B after asof join on 2011-09-09, cbind and na.locf
> will give you 1.5 as opposed to 1.1. I would like to have latest value
> available prior to 2011-09-09 from B which will be 1.1 on 2011-09-09.
> It's a strict inquality for this operation. Would you have any other
> recommendation? Thank you again.
>
Just add a small number to time(b), e.g. replace the first line of AsOf with:
AsOf <- function(a, b,
eps=min(diff(as.numeric(sort(unique(c(as.numeric(time(a)),
as.numeric(time(b))))))))/2) {
time(b) <- time(b) + eps
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-SIG-Finance
mailing list