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).
