Click here to Skip to main content
15,888,209 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900