Description Format Construction Public Fields Public Methods
A Container specifically made for a Individual object and a Household object. It also contains methods that modify both if its contained objects simutaneously.
R6::R6Class object inheriting from Container<-ContainerGeneric<-Generic.
1 | Population$new(ind_data, hh_data, pid_col, hid_col)
|
ind_data::data.table::data.table
Microdata of Individuals/Persons.
hh_data::data.table::data.table
Microdata of Households.
pid_col::character(1)
Individual/Person id column in ind_data
.
hid_col::character(1)
Household id column in hh_data
ind
:: an Individual object
Shorthand to the Individual object. This will be deprecated in a future release.
Please use $get()
to get a reference of object instead of this.
hh
:: an Household object
Shorthand to the Household object. This will be deprecated in a future release.
Please use $get()
to get a reference of object instead of this.
add_population(ind_data, hh_data)
(data.table::data.table()
, data.table::data.table()
)
Add a new population. This requires that all individuals ind_data
belong
to valid households. In the case that hh_data
is not provided, household ids of
ind_data
will be checked against the household ids of the existing households.
All records in ind_data
and hh_data
will be assigned new unique ids to
make sure that their ids are not a duplicate of the ids of existing entities
of their respective entity type.
join_household(ind_ids, hh_ids)
(integer()
, integer()
)
Individuals join their new households and the households' affected attributes,
from the joining of new members, will also be updated. Note! All individuals
must not be in any household prior to joining a new one. Individual's
existing household can be removed using leave_household
.
leave_household(ind_ids)
(integer()
)
Remove the household ids of the individuals in ind_ids and update the households'
affected attributes, from their members leaving. Note that, if the
household has no individuals then it will be removed. This will only cause
a problem if all members of two or more households are to swap their households.
There are no good reasons why that case should be allowed anyway.
remove_emptied_households()
Remove all emptied households.
remove_population(pid, hid)
(integer()
, integer()
)
Remove population from $ind
and $hh
of this Pop
object. If only hid
is given all household members of households in hid
arg will be removed.
To remove only individuals leave hid
to NULL and specify individuals by their ids
in pid
.
get_hhsize(hids = NULL)
(integer()
| NULL
) -> (integer()
)
Get household size of the households in hids
if NULL
then household size
of all households will be returned.
update_hhsize()
Update household size of all household agents.
update()
Masks all the household update functions that need to be adjust after changes
in household members or in their attributes; such as change in partnership status,
change of income, birth.
check_unique_id_cols(ind_data, hh_data = NULL)
(data.table::data.table()
, data.table::data.table()
) -> logical(1)
Check that all id cols of the input data are unique from the existing ids in
their respective objects.
plot_relationship(hid)
(integer(1)
)
Plot the relationship network within the household of hid
.
household_type(hid)
(integer()
) -> (character()
)
Return the household type classification result of the households in hid
.
The result has be one of the following: 'couple_hh', 'couple_hh_with_children',
'lone_parent_hh' and 'non_family_hh'. Note that, the classification doesn't
take into account of the reference family of the household as we have yet to
implement explicit distinction between single family household and multi-family
household. Hence, if there are a couple and a lone parent residing in the same
household it would be classified as a couple_hh
.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.