Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Code chunk that is part of the TRESIS approach to modelling transport behaviour for the book 'Spatial microsimulation with R'
# Households with a car and no professionals
synhhlds <- c(synhhlds,
sample(
filter(hhlds,
numprof == 0,
numcars > 0
)$hhld,
popdist['Car','Other'])
)
synhhldweights <- c(synhhldweights,
rep(popweights['Car','Other'],
popdist['Car','Other']
)
)
synhhldtypes <- c(synhhldtypes,
rep('Car+Other',
popdist['Car','Other']
)
)
# Households with a professional but no car
synhhlds <- c(synhhlds,
sample(
filter(hhlds,
numprof > 0,
numcars == 0
)$hhld,
popdist['NoCar','Professionals'])
)
synhhldweights <- c(synhhldweights,
rep(popweights['NoCar','Professionals'],
popdist['NoCar','Professionals']
)
)
synhhldtypes <- c(synhhldtypes,
rep('NoCar+Professionals',
popdist['NoCar','Professionals']
)
)
# Households with no car and no professionals.
synhhlds <- c(synhhlds,
sample(
filter(hhlds,
numprof == 0,
numcars == 0
)$hhld,
popdist['NoCar','Other'])
)
synhhldweights <- c(synhhldweights,
rep(popweights['NoCar','Other'],
popdist['NoCar','Other']
)
)
synhhldtypes <- c(synhhldtypes,
rep('NoCar+Other',
popdist['NoCar','Other']
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment