Skip to content

Instantly share code, notes, and snippets.

@Robinlovelace
Created September 4, 2015 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Robinlovelace/37e3e08be12f5941a955 to your computer and use it in GitHub Desktop.
Save Robinlovelace/37e3e08be12f5941a955 to your computer and use it in GitHub Desktop.
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