Projects Census 2021 person, family, and dwelling tables from the fplida spine. Person-level records are derived from the spine's demographics, education, occupation, and income attributes; family and dwelling records are derived from the linked people; and Census-specific columns (marital status, language, health conditions, etc.) are generated with age- and occupation-conditioned distributions.
Usage
generate_census(
spine = NULL,
seed = 42L,
output_dir = NULL,
format = c("parquet", "csv"),
return_data = TRUE
)Arguments
- spine
Data.frame (from
generate_spine()) or NULL. If NULL, the most recent spine RDS is loaded fromget_data_path().- seed
Integer. Random seed for Census-specific column generation.
- output_dir
Character or NULL. Base output directory. If NULL, uses
get_data_path(). One of the two must be set.- format
Character. Output format: "parquet" (default) or "csv".
- return_data
Logical. If TRUE (default), return data.frames in memory; if FALSE, write to disk and return metadata only.
Value
A named list with three data.frames:
- person
Person-level records (census_2021_person)
- family
Family-level records (census_2021_family)
- dwelling
Dwelling-level records (census_2021_dwelling)
Dataset and variable information
The ABS Census microdata
website gives information about this dataset. Use dataset_info("CENSUS")
for dataset information. Use variable_info("CENSUS") for variables,
sources, value support, and topic tags.
Examples
if (FALSE) { # \dontrun{
spine <- generate_spine(n = 1000L, seed = 1L)
census <- generate_census(spine = spine, seed = 1L)
str(census$person)
} # }