I have two datasets, big and small.
s_date-c(2005-12-02, 2005-12-01,
2004-11-02,2002-10-05,2000-12-15)
s_id-c(a,a,b,c,d)
b_date- c(2005-12-31, 2005-12-31,
2004-12-31,2002-10-05,2001-10-31,1999-12-31)
b_id-c(a,b,c,d,e,c)
Try this:
merg - merge(big, small, by = id)
f - function(x) {
x$date_.y - max(x$date_.y)
x[x$date_.y = x$date_.x, date_.y] - NA
x
}
do.call(rbind, by(merg, merg$date_.x, f))
On 1/27/06, r user [EMAIL PROTECTED] wrote:
I have two datasets, big and small.