Skip to content
Prev 166847 / 398502 Next

temporal join

The data.table package may be more in line with what you are after, but xts
and zoo can also do what you need in this particular example:
foo 
2009-01-01 "a1"
2009-01-02 "a2"
2009-01-03 "a3"
foo 
2009-01-04 "b1"
foo  foo.1
2009-01-01 "a1" NA   
2009-01-02 "a2" NA   
2009-01-03 "a3" NA   
2009-01-04 NA   "b1"
foo  foo.1
2009-01-04 "a3" "b1" 

cbind/merge will merge along the union on the time-index by default (though
all common joins are supported).  The subsetting by time will then find the
dates (or range of dates/times) that match.

na.locf will carry forward last observations.  That is from zoo; which works
on xts, as xts extends zoo.  

HTH,
Jeff
mckenzig wrote: