
Retrieve Australian Bureau of Statistics (ABS) Census data
Source:R/get_census_data.R
get_census_data.RdDownloads and processes ABS Census DataPack files for a specified Census year and table number. Census DataPacks contain comprehensive demographic, social, and economic data at SA1 geographic level for all of Australia.
Arguments
- census_year
Numeric. The Census year. Must be one of 2011, 2016, or 2021.
- table
Character. The table number to retrieve (e.g., "G01", "G02"). See
abs_census_tablefor a list of available tables and their descriptions.- cache
Logical. If TRUE (default), caches the downloaded DataPack ZIP file for the session, making subsequent requests for other tables from the same Census year much faster. Set to FALSE to always download fresh.
Details
This function retrieves Census data from ABS DataPacks, which are ZIP archives containing CSV files with Census data at SA1 geographic level. The function:
Validates input parameters
Downloads the DataPack ZIP (or uses cached version if available)
Extracts the specified table from the ZIP archive
Note that:
2021 and 2016 Census use General Community Profile (GCP) tables (G01, G02, etc.)
2011 Census uses Basic Community Profile (BCP) tables (B01, B02, etc.)
DataPacks are large (100-400MB), so the first download takes time
With
cache = TRUE, subsequent table requests are fastUse
clear_cacheto remove cached files if needed
See also
abs_census_tables for table descriptions,
clear_cache to remove cached files,
get_boundary_data for boundary correspondence files
Examples
if (FALSE) { # \dontrun{
# Retrieve table G01 (Selected Person Characteristics) for 2021
# First call downloads the DataPack (~380MB)
g01 <- get_census_data(census_year = 2021, table = "G01")
# Second call uses cached ZIP - much faster!
g02 <- get_census_data(census_year = 2021, table = "G02")
# Retrieve 2016 Census data
g01_2016 <- get_census_data(census_year = 2016, table = "G01")
# Retrieve 2011 Census data (uses B prefix)
b01_2011 <- get_census_data(census_year = 2011, table = "B01")
# Clear cached files when done (optional - clears automatically when session ends)
clear_cache()
} # }