0
Trip_hh <-merge(trip, hh, by = "HH_ID", all.x = FALSE, all.y=FALSE, sort = FALSE)
Trip_hh<-Trip_hh[which(Trip_hh$INCOME!=98&Trip_hh$INCOME!=99),]
Mode_Inc<-matrix(,ncol=10,nrow=7)
for(i in 1:10)
{
 for (j in 1:7)
  {
   Mode_Inc[i,j]<- sum(Trip_hh$HH_WEIGHT.x[Trip_hh$INCOME==i&Trip_hh$MODE_AGG==j]/sum(Trip_hh$HH_WEIGHT.x[Trip_hh$INCOME==i]))
   }
 }

Gives me

Error in [<-(*tmp*, i, j, value = sum(Trip_hh$HH_WEIGHT.x[Trip_hh$INCOME == : subscript out of bounds

Desired results: a 10*7 matrix which calculates commutative weights when Income ==1 and mode==1 (so on).

Dhruvi
  • 1
  • please consider giving more information, such as indicated [here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example?rq=1). – shea Oct 09 '17 at 18:18
  • Including a [minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) in your question will increase your chances of getting an answer. – Samuel Oct 09 '17 at 18:20

0 Answers0