search for: previoustripstor

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

Did you mean: previoustripstore
2013 Sep 02
1
R dataframe and looping help
...(1:3)] res<- lapply(seq_len(ncol(dat2)),function(i) {x1<-cbind(dat1[,c(1:3)],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????????????? <N...