Package: canpumf 0.6.0

canpumf: Parse StatCan PUMF Files

Facilitate working with Statistics Canada (StatCan) Public Use Microdata Files (PUMF). Enables downloading of available PUMF data, parsing of metadata from command files or other sources to infer the layout structure, variable labels and value labels as well as missing data values, and returns a connection to a 'DuckDB' database with the labelled data. Data and documentation come from Statistics Canada's Public Use Microdata Files <https://www.statcan.gc.ca/en/microdata/pumf>, distributed under the Statistics Canada Open Licence <https://www.statcan.gc.ca/en/terms-conditions/open-licence>.

Authors:Jens von Bergmann [aut, cre]

canpumf_0.6.0.tar.gz
canpumf_0.6.0.zip(r-4.7-any)canpumf_0.6.0.zip(r-4.6-any)canpumf_0.6.0.zip(r-4.5-any)
canpumf_0.6.0.tgz(r-4.6-any)canpumf_0.6.0.tgz(r-4.5-any)
canpumf_0.6.0.tar.gz(r-4.7-any)canpumf_0.6.0.tar.gz(r-4.6-any)
canpumf_0.6.0.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
canpumf/json (API)

# Install 'canpumf' in R:
install.packages('canpumf', repos = c('https://mountainmath.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/mountainmath/canpumf/issues

Pkgdown/docs site:https://mountainmath.github.io

On CRAN:

Conda:

7.13 score 8 stars 54 scripts 395 downloads 26 exports 47 dependencies

Last updated from:dba3a0a3dd. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK161
source / vignettesOK245
linux-releaseOK174
macos-releaseOK121
macos-oldrelOK97
windows-develOK105
windows-releaseOK101
windows-oldrelOK103
wasm-releaseOK133

Exports:add_bootstrap_weightsadd_lfs_GENDER_SEXadd_lfs_SURVDATEbsw_infoclose_pumfget_lfs_timelineget_pumfget_pumf_connectionlabel_pumf_columnslist_available_lfs_pumf_versionslist_borealis_pumf_cataloguelist_borealis_pumf_fileslist_canpumf_collectionlist_pumf_cachelist_pumf_registrylist_statcan_pumf_catalogueopen_pumf_documentationpumf_freq_validationpumf_label_repairspumf_metadatapumf_modulepumf_registrypumf_registry_entrypumf_var_labelsremove_bootstrap_weightsremove_pumf_cache

Dependencies:askpassbitbit64blobclicliprcpp11crayoncurlDBIdbplyrdplyrduckdbforcatsgenericsgluehavenhmshttrjsonlitelifecyclemagrittrmimeopensslpillarpkgconfigprettyunitsprogresspurrrR6readrrlangrvestselectrstringistringrsystibbletidyrtidyselecttzdbutf8vctrsvroomwithrxml2zip

canpumf Pipeline Architecture
High-level flow | Stage 1 — Locate or download | Version resolution | Stage 2 — Parse metadata | Format detection | Parsers | SPSS monolithic (parse_spss_mono) | SPSS split-file (parse_spss_split) | SAS reading cards (parse_sas_cards) | LFS codebook CSV (parse_lfs_codebook) | CPSS variables CSV (parse_cpss_csv) | SPSS .sav (parse_spss_sav) | PDF Data Dictionary (parse_pdf_dictionary) | PDF frequency codebook (parse_pdf_codebook) | PDF user-guide frequency dictionary (parse_pdf_freq_codebook) | Metadata encoding | Merge | PDF cross-check and label repair | Stage 3 — Build DuckDB | Data file selection | FWF vs. CSV | Trailing junk row removal (FWF only) | Data fixups (pre-label) | Bootstrap weight join (BSW) | Numeric conversion | Code labels → factors | DuckDB write and ENUM enforcement | Multi-module surveys | LFS pipeline | Connection provenance registry | Registry configuration | Newest-sibling inheritance

Last update: 2026-09-25
Started: 2026-06-16

LFS
Timelines | The long timeline, 1976 onward

Last update: 2026-09-25
Started: 2022-03-26

Onboarding a new PUMF
Naming conventions and where to put the files | Smart defaults and the newest-sibling fallback | When the automatic import fails | See what is actually in the directory | Parse the metadata in isolation | Start from an existing entry as a template | Tweak fixups for data-level issues | Build the full table | Promote the configuration into the registry | Summary

Last update: 2026-09-25
Started: 2026-06-16

Working with canpumf
Label repair | Forced moves

Last update: 2026-09-25
Started: 2021-06-05

Working with multi-module PUMF surveys
Loading the primary module | Opening a sibling module | Joining modules for analysis | A second example: the Survey of Household Spending | Cleaning up | Database connections | Notes

Last update: 2026-09-25
Started: 2026-06-22

Bootstrap weights
The method: a resampling bootstrap | Two modes | Where the weights are stored (DuckDB path) | Identifying rows | Stratified bootstrap weights | Estimating uncertainty | Incremental re-runs | Reuse — nothing to do | More replicates requested | Rows added to the survey table | Forcing a full regeneration | Multiple weight columns | Filtered input tables | Connection lifecycle | Inspecting and removing weights

Last update: 2026-06-22
Started: 2026-06-22

Census

Last update: 2026-06-22
Started: 2023-11-12

Readme and manuals

Help Manual

Help pageTopics
Generate bootstrap weights for a PUMF datasetadd_bootstrap_weights
Add a harmonised gender/sex column to an LFS tableadd_lfs_GENDER_SEX
Add a date column to an LFS tableadd_lfs_SURVDATE
Summarise bootstrap weight tables present in a PUMF DuckDB databasebsw_info
Close the DuckDB connection backing a PUMF lazy tableclose_pumf
Harmonised Labour Force Survey timeline, 1976 onwardget_lfs_timeline
Get a Statistics Canada PUMF dataset as a lazy DuckDB tableget_pumf
Get a read-write DuckDB connection to a PUMF databaseget_pumf_connection
Rename PUMF table columns to human-readable variable labelslabel_pumf_columns
List available LFS PUMF versionslist_available_lfs_pumf_versions
Browse the Statistics Canada PUMF collection on Borealislist_borealis_pumf_catalogue
List the files of a Borealis PUMF datasetlist_borealis_pumf_files
List Statistics Canada PUMF datasets supported by canpumflist_canpumf_collection
List the contents of the local canpumf cachelist_pumf_cache
Overview of all built-in registry entrieslist_pumf_registry
Crawl the full Statistics Canada PUMF catalogue (experimental)list_statcan_pumf_catalogue
Open PUMF documentation in the browseropen_pumf_documentation
Inspect the PDF-versus-microdata frequency validationpumf_freq_validation
Inspect label repairs and divergences found against the PDF data dictionarypumf_label_repairs
Download and parse PUMF metadata without building a DuckDB tablepumf_metadata
Open a sibling module of a multi-module surveypumf_module
Inspect a survey's registry configurationpumf_registry
Construct a custom PUMF registry entrypumf_registry_entry
Retrieve variable labels as a tibblepumf_var_labels
Remove bootstrap weight tables and views from a PUMF DuckDB databaseremove_bootstrap_weights
Remove a PUMF version from the local cacheremove_pumf_cache