
Assign Household Identifiers to Agents
Source:R/all_generics.R, R/methods-ReplicaStructure.R
agentToHousehold.RdWrites household identifiers from the household structures
stored within a ReplicaStructure object back into
the associated synthetic population.
Arguments
- object
A
ReplicaStructureobject.
Value
An updated ReplicaStructure object
containing household identifiers in the synthetic population.
Details
Each agent belonging to a generated household receives a
value in the household_id column corresponding to the
household to which they belong.
This method is typically called after household generation
has completed and before household-level summary tables are
created using householdsToDataFrame.
Household identifiers are obtained from the
households slot.
For each household:
Household members listed in
household$allare identified.The corresponding household identifier is written to the synthetic population.
After execution, household assignments can be accessed via:
object@df_synth_pop$household_idThis method is used as part of the household-generation
workflow implemented by
enhance for
ReplicaGrouper objects.
Examples
if (FALSE) { # \dontrun{
hh <- agentToHousehold(
hh
)
head(
hh@df_synth_pop
)
} # }