Displaying 1 result from an estimated 1 matches for "beforetran".
2010 Jun 03
2
lapply or data.table to find a unit's previous transaction
...with(Data,
??Data[
??UnitID== substr(x, 1, nchar(n))&
??TranDt< Data[TranID== x, "TranDt"], ]
??))
??)
#I do get warnings about missing data because some transactions have
no predecessor.
#Some transactions have no previous transactions, others have many so
I pick the most recent
BeforeTran<- lapply(seq_along(PreTran), function(x) (
with(PreTran[[x]], PreTran[[x]][which(TranDt== max(TranDt)), ])))
#I need to add the current transaction's TranID to the list so I can merge later
BeforeTran<- lapply(seq_along(PreTran), function(x) (
transform(BeforeTran[[x]], TranID= TranList...