search for: nexttripstore

Displaying 1 result from an estimated 1 matches for "nexttripstore".

2013 Sep 02
1
R dataframe and looping help
...],dat2[,i]);colnames(x1)[4]<- colnames(dat2)[i];x2<-x1[x1[,4]!=0,];within(x2, {daysbetweentrips<-unlist(tapply(as.Date(x2$TripDate,"%d-%b-%y"),list(x2$CustID),function(x) c(NA,as.numeric(diff(x)))));previoustripstore<-ave(x2$Store,x2$CustID,FUN=function(x) c(NA,x[-length(x)]));Nexttripstore<- ave(x2$Store,x2$CustID,FUN=function(x) c(x[-1],NA))})}) ?res #[[1]] ?# CustID? TripDate Store Bread Nexttripstore previoustripstore daysbetweentrips #1????? 1? 2-Jan-12???? a???? 2???????????? a????????????? <NA>?????????????? NA #3????? 1? 9-Jan-12???? a???? 3???????????? a???????????...