Skip to content

Commit

Permalink
Correct for situation when there is 0 total employment in a Bzone
Browse files Browse the repository at this point in the history
  • Loading branch information
dflynn-volpe authored and jrawbits committed Nov 29, 2021
1 parent 3e7465e commit e664a06
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions sources/modules/VELandUse/R/LocateEmployment.R
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,8 @@ LocateEmployment <- function(L) {
#Tabulate workers by residence Bzone
Wkr_Bz <- tapply(L$Year$Household$Workers, L$Year$Household$Bzone, sum)[Bz]
Wkr_Bz[is.na(Wkr_Bz)] <- 0

names(Wkr_Bz) = Bz # After filling in NA's, need to give the names of Bzones again

#Allocate workers by origin and destination using IPF
#----------------------------------------------------
#Use IPF with seed matrix that is inverse of distance between Bzones
Expand All @@ -391,7 +392,12 @@ LocateEmployment <- function(L) {
round(TotEmp_Bz * (L$Year$Bzone$RetEmp / L$Year$Bzone$TotEmp))
SvcEmp_Bz <-
round(TotEmp_Bz * L$Year$Bzone$SvcEmp / L$Year$Bzone$TotEmp)


# Fill NA with 0.
# NA occur if total employment in a Bzone is 0
RetEmp_Bz[is.na(RetEmp_Bz)] = 0
SvcEmp_Bz[is.na(SvcEmp_Bz)] = 0

#Create worker table
#-------------------
#Identify households having workers
Expand Down

0 comments on commit e664a06

Please sign in to comment.