for(i in 1:dim(dataset)[1]){
hitlist=trainmy2[trainmy2$VisitNumber==dataset[i,2],]
dayofweek=names(hitlist)[3:9][hitlist[1,3:9]>0]
dataset[i,dayofweek]=1
hitlist2=Copy_Walmart[Copy_Walmart$VisitNumber==dataset[i,2],]
agg=aggregate(ScanCount~DepartmentDescription,data=hitlist2,sum)
sub1<-gsub("",".",paste0(names(agg)[1],".",agg[,1]))
sub2<-gsub("-",".",sub1)
sub3<-gsub("&",".",sub2)
sub4<-gsub("/",".",sub3)
sub5<-gsub(",",".",sub4)
dataset[i,sub5]=agg[,2]
print(i)
}
What I have tried:
I not really able to understand what is wrong with this.Please help me to understand