Displaying 1 result from an estimated 1 matches for "tranlist2".
2010 Jun 03
2
lapply or data.table to find a unit's previous transaction
..., I convert from a list to a data frame
BeforeTran<- do.call("rbind", BeforeTran)
#I have used a combination of data.table and for loops, but that seems
cheesey and doesn't preform much better.
library(data.table)
#First I create a list of all the previous transactions by unit
TranList2<- vector(nrow(Data), mode= "list")
names(TranList2)<- levels(Data$TranID)
DataDT<- data.table(Data)
#Use a for loop and data.table to find the date of the previous transaction
for (i in levels(Data$TranID)) {
if (DataDT[UnitID== substr(i, 1, nchar(n))&
?? TranDt<= (DataD...