The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
The package exported 31 functions, several of them variants of one
another. 0.7.0 folds them into 20. Functions that 0.6.0 exported keep
working for now, with a deprecation warning (see
?"canpumf-deprecated"), and will be removed in a later
release.
list_pumf_catalogue(source) replaces
the four catalogue listers: list_canpumf_collection()
(source = "canpumf", the default),
list_statcan_pumf_catalogue() ("statcan"),
list_borealis_pumf_catalogue() ("borealis")
and list_available_lfs_pumf_versions()
("lfs").get_pumf("LFS_TIMELINE") replaces
get_lfs_timeline(), with sources = and
refresh = "auto" as before; the timeline is documented
under ?lfs_timeline.pumf_dictionary(x, what =) gains
what = "variables", "values" and
"topcodes", and the dictionary has the columns
description_en, description_fr and
applied_as. what = "variables" replaces
pumf_var_labels().pumf_pdf_crosscheck(tbl, report)
replaces pumf_label_repairs()
(report = "repairs", the default) and
pumf_freq_validation() ("validation").add_lfs_columns(tbl, columns) replaces
add_lfs_SURVDATE() and add_lfs_GENDER_SEX(),
and adds both columns by default.pumf_registry() without a version
returns the overview that list_pumf_registry() returned,
optionally for one series (pumf_registry("GSS")).get_pumf_connection() is deprecated:
get_pumf(series, version, read_only = FALSE) opens the same
read-write connection, and dbplyr::remote_con() of the
result is the connection itself.get_pumf("TCP", "1881") loads the 100% file of
the 1881 Census released by The Canadian Peoples / Les
populations canadiennes project on Borealis
(doi:10.5683/SP3/FXZEVO, CC0): 4,277,810 enumerated persons
with names, ages, birthplaces, religions, origins, occupations and their
census geography. It is the first series in the registry that is not a
Statistics Canada PUMF, and the only TCP vintage whose data file is
open; 1871 and 1891 to 1921 need a project application.parse_json_value_labels().
It has no variable labels and no French text, so the registry supplies
the 52 variable labels in both languages (see the ledger
tests/testthat/override_verification.csv for which of them
the project’s documentation confirms), and the value labels are English
in both languages.csv_reader = "duckdb" keeps the records out
of R: DuckDB reads the file, R only converts and labels the distinct
values of the numeric and coded columns, and DuckDB joins the results
back when it writes the table. The 1.1 GB file builds in half a minute
with about 2 GB of memory, where readr needs a minute and 7 to 8 GB, and
the table is identical. The build runs under a DuckDB memory limit of 1
GB, which options(canpumf.native_memory_limit = "4GB")
raises for a faster build (13 seconds at 4 GB) and NULL
removes.<name>.csv.gz;
the 1881 file is an 88 MB transfer and takes 88 MB on disk instead of
1.1 GB). The file is requested as a zip bundle, which Borealis
compresses on the fly, and recompressed to gzip without the uncompressed
copy ever being written; readr and DuckDB both read the compressed file
directly. When Borealis leaves the file out of the bundle (its zip size
limit), the plain file is downloaded and compressed instead. Caches that
already hold an uncompressed Borealis CSV keep working.data_fixups, first used here.
fix_mojibake = TRUE repairs double-encoded UTF-8 in the
text columns of the data ("Québec"), which affects a
thousand distinct names and places of the 1881 file.
removed_records moves the records the producer flags for
removal (1,137 crossed-out, duplicate and blank lines,
REMOVE_TCP = 1) out of the main table into a sidecar table
(below). keep_unlabelled_codes keeps a code without a value
label as a level named by the code instead of NA: 98
occupation codes of the 1881 file, on 9,306 records, are not in its
dictionary.get_pumf("CCRI", "1911") loads the Canadian
Century Research Infrastructure sample of the 1911 Census from
the ODESI deposit on Borealis (doi:10.5683/SP3/MDTWGJ):
371,373 persons in a 5% sample of dwellings, with names, places and
occupations as transcribed next to the project’s coded variables (101
variables). It is the only CCRI vintage with an openly downloadable
file; the registry pins the deposit’s CSV, SAS card and PDFs, because
the file selection would otherwise take the 344 MB .sav for
its labels.variables.csv
has two optional columns, description_en and
description_fr, for the longer text some documentation
carries beside a label. pumf_dictionary(what = "variables")
and pumf_metadata()$variables return them (NA
for the surveys that document a label only). The CCRI card describes
every variable with a sentence
('The year in which persons who were formerly aliens became naturalized citizens of the British Empire.');
the new fixup labels_as_description = TRUE keeps those
sentences as the descriptions, and the registry supplies the short
labels in both languages. The apostrophes and dashes the card loses to
its code page (individual?s) are repaired.parse_sas_odesi(), which
now handles character ($) columns, special missing values
(.D='Blank') and the
IF v = 99999001 THEN v = .D recodes, turning them into code
rows and a missing range. detect_formats() uses such a card
only when no other dictionary is present.data_fixups, first used here.
rejoin_split_records = TRUE repairs a CSV in which a line
break inside a field has split a record over two lines (15 records of
the 1911 file, in an address field); a record the repair cannot complete
is an error. column_encoding = list(CP850 = c(...)) decodes
named columns with a code page other than the file’s (two standardized
text columns of the 1911 file are DOS CP850 inside a CP1252 file).
text_missing_codes blanks the eight-digit codes the
enumeration uses for “Blank”, “Illegible”, “Damaged”, … when they appear
in text columns, and records them in the sentinel sidecar under the
labels sentinel_labels supplies in both languages. A
variable can now take both missing_codes and
missing_supplement (CCRI’s
YEAR_OF_NATURALIZATION: the status codes 1 to 3 and the
missing range).HOURS_WORKED_CHIEF_OCC 90000001 “Full Time”) stay numeric,
with the codes set aside in the sentinel sidecar; the within-dwelling
and within-household sequence numbers are zero-padded
(str_pad) so they sort as text.list_pumf_catalogue("borealis") now lists the census
microdata Statistics Canada has never published: the historical census
samples deposited by ODESI (1871, the four regional 1881 files, 1891,
1901 and the CCRI 1911 sample), which the title filter of the
census dataverse used to drop, and the open TCP complete
count (dataverse TCPCensusData; 1881 only, the restricted
years are left out). A census dataset is kept when its
title names a PUMF or it ships an SPSS data file, so aggregate products
(profiles, counts, GIS layers) still stay out. year now
recognises 19th-century titles.pumf_sidecar() gives access to the
tables a build writes beside the survey table.
pumf_sidecar(tbl, "sentinels") is the table of sentinel
codes described next; pumf_sidecar(tbl, "removed") returns
the records a survey’s registry entry sets aside (TCP 1881), and
join = TRUE appends them to the data.
pumf_sidecar(tbl) lists the ones a survey has, with their
row counts.9999999 / 8888888). canpumf
converts them to NA so that sums and means are right, which
used to lose the reason. Every table built by this version therefore
comes with a pumf_sentinels_<table> sidecar holding,
for each record with at least one sentinel, the sentinel’s label as an
ENUM column per affected variable ("Not applicable",
"Not available", "NOT APPLICABLE"),
NA where the main table has a value. New
pumf_sidecar(tbl, "sentinels") returns it and
pumf_sidecar(tbl, "sentinels", join = TRUE) joins it onto
the data as <VAR>_sentinel columns;
pumf_sidecar(tbl) lists the sidecar tables a survey has.
Labels come from the command file where it labels the code (also for a
force_numeric variable such as GSS 17 WKWEHR,
whose “Not stated” is labelled in the sidecar although its top-code
label is dropped from the table), otherwise from the new registry field
sentinel_labels, otherwise the digits are shown.pumf_row_id
column, the record’s 1-based position in the data file, as the
join key for the sidecar tables. add_bootstrap_weights()
uses it as the key when the registry names none, instead of adding a
rowid-derived column at write time.metadata/ directory,
from R or any other DuckDB client. Three layers are written beside the
survey tables. (1) The build stamp pumf_build_info (one row
per table) records which canpumf and duckdb built it and when, and the
provenance of the data: the survey (series,
version, lang, module), where the
data came from (source: statcan,
borealis, or deposit for a file placed in the
cache by hand; the download URL or the Borealis DOI and dataset title;
the download date; the data file read), the licence the data are
distributed under (the Statistics Canada Open Licence, or the licence a
Borealis dataset declares) and the names of the registry data fixups
that applied. Stage 1 keeps the download URL in a
statcan_manifest.csv beside a StatCan zip, as the Borealis
source already did in borealis_manifest.csv, which now also
carries the dataset’s licence. (2) The bilingual dictionary of every
table, the rows pumf_dictionary() returns, is stored in the
table pumf_dictionary (keyed by table, with
applied_as), and pumf_dictionary(),
pumf_translate() and label_pumf_columns() read
it from there; metadata/codes_applied.csv is still written
and remains the fallback for a database built before this table existed.
(3) Every labelled column carries its variable label in the table’s
language as a DuckDB column comment, and every table a one-line
description (SFS 2019 [eng] - <title>), readable with
duckdb_columns() and duckdb_tables(). A tbl
opened on the file with DBI::dbConnect() directly, without
get_pumf(), now finds its provenance in the stamp, so
label_pumf_columns(), pumf_dictionary() and
pumf_sidecar() work on it.
pumf_sidecar(tbl, "provenance") returns the stamp row,
pumf_sidecar(tbl) lists it (kind info), and
list_pumf_cache() gained source and
licence columns next to built_with
(NA for a database built before 0.7.0). The longitudinal
databases (LFS, LFS_HIST) are stamped and described the same way on
their next append; remove_pumf_cache(lang = ) drops the
dropped language’s stamp and dictionary rows and keeps the comments
through the compaction. A registry label fix now reaches a built file
through refresh = TRUE only, since the file holds its own
copy of the dictionary. The provenance can be stated or corrected by
hand, for data deposited in the cache without a download and for a
licence or title the automatic record gets wrong: a file
pumf_provenance.csv (columns field,
value) beside the raw data in the version directory, or the
new provenance = list(...) field of
pumf_registry_entry(), sets source,
source_url, source_doi,
source_title, downloaded,
licence, licence_url and the new stamp columns
citation and note; the file wins over the
registry, both win over the download manifests, and the stamp lists the
fields set this way in user_fields. Both are read when the
database is built, so a change takes refresh = TRUE.get_pumf() says so once per session
when it opens one, as a message rather than a warning, since the values
are still those of the version that built them. The message also names
the merged value labels (below). A table stamped by a 0.7.0 development
build whose metadata has no codes_applied.csv gets its own
one-line message, since pumf_dictionary() may not match its
levels. Rebuild with get_pumf(..., refresh = TRUE), or
silence the message with
options(canpumf.stale_cache_message = FALSE).
pumf_sidecar(tbl, "sentinels") on such a table asks for the
rebuild. Everything else keeps working on an old cache.remove_bootstrap_weights() no longer drops
pumf_row_id, which is the permanent key now. The column
that 0.6.0 added to a table for its bootstrap weights is left in place
as well.pumf_translate() relabels a finished result
in the other language. An analysis is carried out in one
language, but the result is sometimes reported in both.
pumf_translate(result, "fra", dict = tbl) takes a collected
data frame (typically a summary table), translates its factor levels,
the values of character columns that belong to a survey variable, and
column names that are variable labels from
label_pumf_columns(), and returns the data frame otherwise
unchanged. Grouped tibbles keep their groups. The
<VAR>_sentinel columns of
pumf_sidecar(tbl, "sentinels", join = TRUE) are translated
with their variable. It works in either direction and needs only the
survey’s metadata, so a French table can be produced from a cache built
in English alone.fct_collapse(),
case_when() recodes) are kept and reported once as a
warning. Supply them through custom =, as a named vector in
the direction of the translation (c(West = "Ouest")) or a
data frame with label_en, label_fr and an
optional name. Custom entries override the dictionary and
also rename a matching column. Two source levels that translate to one
label are merged. The attribute "pumf_translation" records
what happened to every label.pumf_dictionary() returns the survey’s
variable and value labels in both languages as one tibble
(name, val, label_en,
label_fr), from a get_pumf() tbl or a
series/version pair. It is the lookup pumf_translate()
uses, module-aware, merged across every loaded version for
"LFS" and "LFS_HIST", and available for
get_pumf("LFS_TIMELINE"). It also carries the registry’s
labels for Census sentinel codes. The longitudinal spec gained a
codes() accessor beside variables().pumf_registry_entry() now recognises
sentinel_labels as a data_fixups field instead
of warning about it.collect_pumf(tbl, labels, close)
collects a get_pumf() table and keeps its coded column
names, attaching each variable label as the column’s label
attribute (the haven/labelled convention the RStudio viewer, gt and
labelled::look_for() read), plus a description
attribute where the metadata has one. labels = "name"
renames instead, as label_pumf_columns() does;
close = TRUE closes the connection after collecting. The
frame carries a pumf_provenance attribute, so
pumf_dictionary(), label_pumf_columns() and
pumf_translate() (which then needs no dict,
and translates the attributes too) work on it after
close_pumf().Codes of one variable that share a label are now kept
apart. The command files give several codes the same label more
often than one would hope: genuinely shared categories (Census 1986
HHMOTG “Other” on 3 and 6, ITS 2018 VSTRC01
“Northern” on the region codes 0635 and 0730, PALS 2001
NAICSPALS “Not applicable” on 01 and 93), scale points
printed as |, ??? or ... across a
whole code range (CHSS PSC_075, GSS 31 SLM_01,
GSS 17 LS_Q110), and truncated labels that collide. The
factor built from such labels merged the categories and lost the code.
The build now checks the data: when at least two codes sharing a label
occur, every member of the group gets its code appended, per language:
"Other (3)", "Other (6)". A label whose other
codes never occur stays as documented (CHS 2018 PITM_05
declares 5 and 8 both “Do not know” but only 8 appears), so 100
variables in 22 survey versions of the verified datasets gain a suffix
and 22 more keep their label. A collision in English alone leaves the
French labels untouched. The same rule applies to the sentinel sidecar
(two sentinel codes labelled NA by the registry become
NA (99) and NA (999)) and to the source labels
the LFS timeline maps; none of the LFS or LFS_HIST variables is
affected. Stage 3 records the labels it applied in
metadata/codes_applied.csv, which
pumf_dictionary() (and therefore
pumf_translate()) reads, so the dictionary matches the
table by construction; for a cache built before 0.7.0 it returns the
documented labels, which is what such a table shows. Existing caches
keep the merged levels until they are rebuilt with
refresh = TRUE.
New pumf_dictionary(what = "topcodes") lists
the labelled values that stay numbers. A count, age or amount
variable whose only labels sit on its top code (“75 and more” on GSS 17
WKWEHR, “85 years and over” on an age), its bottom code or
a labelled zero (“None”) is kept numeric, so that its unlabelled values
are not lost, and the label is dropped from the table: a 75 is a plain
75 although it stands for 75 or more.
pumf_dictionary(tbl, what = "topcodes") (or
pumf_dictionary("GSS", "Cycle 17 (2003)", what = "topcodes"))
returns these values with their labels in both languages, so that a mean
or a range can be read with the ceiling in mind. Its sentinel codes
(“Not stated”) are not listed, since they become NA and are
reported by pumf_sidecar(tbl, "sentinels"). To support it,
metadata/codes_applied.csv gained an
applied_as column recording how the build applied each code
(level of a factor column, value kept as a
number, sentinel blanked); a cache built without it is
asked to be rebuilt with refresh = TRUE.
New data_fixups field
codes_override replaces the label of a code the
command file declares, where the user guide says otherwise. First use:
Census 1986 households HHMOTG (mother tongue of the
household maintainer), whose codes 3 and 6 are both “Other” in the SPSS
file; the guide lists 3 under Single responses and 6 under
Multiple responses, and the spouse variable SPMOTG
spells the same categories out, so they are now “Other single responses”
/ “Other multiple responses” (French “Autres réponses uniques” / “Autres
réponses multiples”). Like every manual override it has rows in
tests/testthat/override_verification.csv.
remove_pumf_cache() gained a lang
argument that drops one language from a bilingual build and
gives the space back.
remove_pumf_cache("SFS", "2019", lang = "fra") drops the
French table, its sidecar tables, the bootstrap-weight views 0.6.0 made
for it and its build-stamp and dictionary rows, keeps the English
tables, the shared bootstrap-weight tables, the metadata and the raw
files, and then compacts the DuckDB file by copying what remains into a
fresh file, since DuckDB does not truncate a file when a table is
dropped. Dropping the last language deletes the file. It needs the write
lock, so open tbls have to be closed first; the longitudinal series are
not supported.get_pumf("LFS", ...) and
list_pumf_catalogue("lfs") no longer need the LFS page. The
page is read only when the newest expected file is missing. The pre-2006
EFT months are a fixed list.options(canpumf.browser = FALSE) turns this off. A download
refused by the check is fetched through the same browser.get_pumf() gives
the message and returns NULL, as it does for a failed
download, instead of stopping with an error (CRAN’s
--run-donttest check of 0.6.0 failed in the
add_lfs_SURVDATE() example this way).<cache_path>/<series>/<version>/) and
run the same get_pumf() call again.get_pumf("LFS", "2023") reported that the version does not
exist. The fallback now lists the annual files, whose URLs are stable
(the monthly files rotate off the page and are not included), and a
version missing from a hard-coded list says that StatCan is currently
unreachable and the list may be incomplete.A connection closed without close_pumf() no
longer passes its survey to the next one. The provenance
registry is keyed by the connection’s memory address, which is reused
once the closed connection is garbage-collected; a stale entry is now
dropped when looked up.
canpumf works with duckdb 1.5.6, which no longer
ignores read_only when the R session already has the
database file open in the other mode and fails in
dbConnect() instead. A write attempted while a
get_pumf() tbl holds the file
(remove_pumf_cache(lang = ), a build of the other language)
reported duckdb’s error instead of the instruction to
close_pumf() the tbl; it reports the instruction again, and
so does get_pumf(read_only = FALSE), which earlier duckdb
versions answered with a connection that could not write. A read while
the session holds the file read-write
(get_pumf(read_only = FALSE)) failed, and
list_pumf_cache() lost its built_with value;
reads share that connection’s database instance again, as they did
before.
add_bootstrap_weights() works on the connection
of the table it is given, and stores weights only through a write
connection. Up to 0.6.0 it closed that connection to get write
access to the file, wrote the weights and a view joining them to the
survey table, and returned a tbl on the view after replaying the input’s
filter() from its SQL. That invalidated every other tbl on
the file, failed while another session had the database open, and lost
or misread what the input carried (a select(), column
labels, a label containing “where”). Now nothing is closed or reopened:
get_pumf(..., read_only = FALSE)
the weights are stored in the database (table
pumf_bsw_<weight>, as before) and reused by every
later call, in this session or another.get_pumf() default) stored
weights are used when they cover the request. Otherwise the weights go
to a temporary table of that connection
(tmp_pumf_bsw_<weight>), which lasts until the
connection is closed, and the database file is not touched. A message
says so and names read_only = FALSE; a warning is added
when the temporary weights exceed about 2 GB. More replicates than are
stored, or rows added since, are handled in the temporary table, with
the stored replicates copied into it.get_pumf() |> add_bootstrap_weights() no longer writes
to the cache. Pass seed to get the same temporary weights
in every session, or open the table with read_only = FALSE
once to store them.filter(), select(), mutate()
and label_pumf_columns() applied before the call are kept
as they are, and the “operations that cannot be replayed” warning is
gone. The column(s) that identify the rows have to be among the columns
of the input, under their coded name or their label; a
select() or summarise() that dropped them gets
an error saying to add the weights first. An arrange()
before the call does not survive the join (dbplyr warns about it); sort
the result instead.bsw_join_key, else pumf_row_id, and for
"LFS" and "LFS_HIST" the record key
SURVYEAR, SURVMNTH, REC_NUM, so
bootstrap weights work on the longitudinal tables. id_col
may name several columns, and a key with missing or duplicated values is
refused instead of producing a many-to-many join. The survey table is
never altered: a table built before 0.7.0 that has no key column needs
get_pumf(..., refresh = TRUE) or an id_col.
Weights stored by 0.6.0 keep working, on the key they were written with,
and the <table>_bsw_<weight> views it made are
dropped when weights are next written or removed.pumf_bsw_<weight>_<module> for
a secondary module); before, a tbl of a secondary module was answered
with the primary table and its weights. A
get_pumf("LFS_TIMELINE") tbl is refused with the advice to
collect() first, since it spans two databases.bsw_info() also reports the replicate weights
that came with the survey, and says which kind each row is. The
new column source is "survey" for the survey’s
own replicates, which are columns of the survey table
(BSW1-BSW1000, Census
WT1-WT16, GSS
WTBS_001-WTBS_500), and
"generated" for the weights of
add_bootstrap_weights(); before, a table with only the
survey’s weights was reported as having none. The survey’s replicates
are recognised as a family of numeric columns numbered from 1 without
gaps that the metadata labels as bootstrap or replicate weights or does
not describe at all. The columns are now source,
weight_col (NA for the survey’s own),
prefix (the common prefix of the replicate columns),
bsw_table, temporary,
n_replicates and size_mb.
temporary replaces view_name and
view_exists, and size_mb is the uncompressed
size of the replicates (rows x replicates x 8 bytes); it used to show
the row count divided by 1e6.remove_bootstrap_weights() drops the
temporary weights of the connection, and the stored ones on a write
connection. On a read-only connection stored weights are kept, with an
error saying how to open the table when there was nothing else to
remove. It no longer closes the connection either, and
weight_col may be a column label.close_pumf(), a
refresh or a removal of its database) is reported by all three functions
with the advice to call get_pumf() again, instead of
duckdb’s “connection is no longer valid”.add_bootstrap_weights() on the same tbl in three chunks. It
now adds the weights once and keeps the returned tbl, and the
Bootstrap weights vignette describes the two storage
modes.get_pumf("CIUS", "2005") through
"2022"). Each bundle names its data file differently and
ships it beside other text files, so each release has a registry entry
with a file_mask. PUMFID is text in every
release: 2007 and 2009 declare it (A) in the DATA LIST, and
the 2005, 2018 and 2020 entries keep it text with
force_character (2005 zero-pads it). Record counts and
weighted totals match the codebooks.Data.zip, which holds
RAW.zip, which holds the data; Stage 1 only unpacked the
first level and then found no metadata. Extraction now repeats until
nothing new turns up, visiting each archive once (the accented
Data_Données.zip of 2020 never looks fully extracted to the
name comparison, so a naive loop would unpack it forever).(A) declaration makes the variable
text. The monolithic SPSS parser typed PUMFID (A)
numeric when the card had no FORMATS section (CIUS 2007/2009). The DATA
LIST parser now records the (A) annotations and the type
derivation honours them.Missing Values in mixed case is read.
CIUS 2009 heads its missing-value block Missing Values; the
section keywords of the monolithic SPSS parser are now matched
case-insensitively.get_pumf("CIUS", "2022")), downloaded from the StatCan
catalogue. The registry entry picks the data file out of a bundle that
also ships a GTAB copy, and labels the person weight WTPG
from the user guide (“Survey weight (person level)” / “Poids d’enquête
(niveau des personnes)”), which no command file names.WRPG1-WRPG1000,
and the GSS and SGVP replicate weights
WTBS_002-WTBS_500 beside a labelled
WTBS_001, had no row in variables.csv, so
Stage 3 never converted them and sum(WTPG) failed in
DuckDB. A layout column read with implied decimals is a measure by
declaration: merge_metadata() now adds it to the variable
table as an unlabelled numeric variable
(.promote_layout_numeric()), and the build stores it as
DOUBLE, at the scale the file stores it. A layout-only column without
decimals (the CIUS PUMFID, a GSS FILLER) stays
out of the table and remains character, since an identifier keeps its
leading zeros that way. The “Variables in layout but not in variable
labels” warning now names only those. The lang = "fra"
warning about variables with no label in either language skips the
promoted columns, and so does the French-coverage check. Rebuild with
refresh = TRUE to get the numeric columns.force_numeric name that the metadata does not declare
but the data carry (a layout-only column in a hand-written
pumf_registry_entry()) now gets an unlabelled numeric row
instead of being silently ignored.WGHT_EPI on. StatCan’s SPSS command file
(TU_ET_2022_Episode_PUMF-FMGD_i.sps, revised in March 2025
to match the codebook’s printed positions) orders the variables
differently from its SAS card (TU_ET_2022_Episode_i.SAS),
and only the SAS card reads the 5,071-byte records: under it
DURATION == ENDMIN - STARTMIN in every one of the 168,078
episodes and every codebook frequency is reproduced
(LOCATION 3300 “At home or on property” 121,465 episodes,
ACTIVITY 0100 “Sleeping” 27,313, DUR_03,
TUI_06A, TUI_07, TUI_15, …),
while under the SPSS columns the episode weight WEPI_001
read a thousand times too large and the classification codes landed on
the wrong variables. The SPSS card also documents TUI_D81
at column 32, which is not on the file. canpumf took the layout from the
SPSS card, so every Episode column after the weight was wrong. The Main
file is not affected, and neither is Cycle 29 (2015).layout_file (entry
level or per module) names, as a regular expression on the file name,
the one command file whose DATA LIST or SAS
INPUT is the record layout; Stage 2 then replaces the
merged layout with that file’s. A name the card declares twice keeps its
first field (the Cycle 36 card reads INSTANCE at 7-9 and
again at 37-39, identical in every record).
pumf_registry_entry() accepts it, and like every manual
override it has a row in
tests/testthat/override_verification.csv. The Cycle 36
Episode module uses it to read the SAS card, and its former
force_numeric for ACTIVITY,
LOCATION, TUI_01 and TUI_03 is
gone: read at the right columns, every value of these is a documented
code, and they are ordinary factors.@pos NAME w.d line that ends with a
/* from - to */ comment now yields its decimals (the Cycle
36 cards comment every field), so the 500 WEPI_* replicate
weights are numeric like the GSS WTBS_* ones above.get_pumf("GSS", "Cycle 36 (2022)", refresh = TRUE) (English
first with refresh = TRUE, then French without, since the
refresh replaces the whole database).MOB1, PR1,
CIP2000, NOC11, PKID0_1,
PKID25, …). The English SPSS command file heads their
VALUE LABELS blocks with a decorated name
(MOB1_), which no DATA LIST declares, and the
English-keyed bilingual join then lost the correctly-spelled French
labels too. The mono SPSS parser now attaches such a block to the
declared variable when stripping the trailing underscores lands on one
that has no block of its own. A variable whose name genuinely ends in
_ is untouched.MISSING VALUES and label none of them, and the 7-digit
na_values guard only catches the 7-character fields. The
user guides document each one, and they are now
missing_codes per entry:
888888/999999 for the six-digit amounts
(INCTAX, TOTINC_AT, INVST,
RETIR, OTINC, SEMPI,
EFDIMBM), 88888/99999 for the
five-digit ones (CHDBN, CHLDC,
CQPPB, EICBN, GOVTI,
GTRFS, OASGI),
8888/9999 for GROSRT and
OMP, 888/999 for
FCOND, and the 2006 hours 999 / weeks
99. Every code is recorded in the override ledger with its
user-guide line.MISSING VALUES list was dropped, and zero incomes were
blanked. HRSWK ( 0,999 ) and
WKSWK ( 0,99 ) (and the household-file HRSWK*
/ WKSWK* counterparts) only blanked the 0,
leaving 999 / 99 hours and weeks in the data,
while the income declarations (TOTINC ( 0,999999 ),
HHINC ( 0 )) turned every zero income into NA.
The codebooks flag both codes M, but the 0 is “ZERO” /
“ZERO HOURS” / “ZERO WEEKS”, excluded from the codebook means yet a
value, not a non-response. Now only the “NOT APPLICABLE” codes
(999, 99, 999999,
99999, and the 0 / 99 of the
age-of-spouse variables) are missing_codes, labelled
NOT APPLICABLE in the sentinel companion, and every zero
income and zero hour stays 0. The 1981 data files code the
income “not applicable” (persons under 15, institutional residents,
family members a family does not have) as 0 rather than the
codebook’s 999999, so the income variables carry
0 for both and have no sentinels.AGEFTMAR 88) and 1976
(AGE, AGEHD 88) are real ages, and 2006
HRSWRK 98 is the valid “84 hours or more” average.open_pumf_documentation() accepts the version
aliases of get_pumf().
open_pumf_documentation("Census", "2021") reported “No data
found” although get_pumf("Census", "2021") had built
"2021 (individuals)", because the version was used as the
cache directory name without being resolved. The same went for the other
Census years, the loose Census forms ("1986 families") and
the GSS aliases ("2017", "Cycle 31").
open_pumf_documentation() names the cached versions
of the series when the requested one is not in the cache
(open_pumf_documentation("TCP", "1981"):
Cached TCP versions: "1881"), and its import notes now also
list a repaired text encoding, records set aside
(removed_records), unlabelled codes kept under their code
and the number of variable labels supplied by the registry.
pumf_dictionary() accepts them as well when called
with a series name: pumf_dictionary("Census", "2021")
stopped with “Metadata directory not found”.
remove_pumf_cache() still takes the exact version only, so
that a loose name never decides what is deleted.
The LFS microdata now span 50 years. The monthly public-use files for 1976–2005, which Statistics Canada does not post for download, are loaded from Borealis and can be stacked with the current LFS in one harmonised table.
"LFS_HIST" loads the monthly LFS PUMFs for
January 1976 to December 2005 from Borealis (ODESI), in the legacy
pre-2017 layout: get_pumf("LFS_HIST", "1995-06") loads one
month, and get_pumf("LFS_HIST", "1995") loads all twelve
months of a year. Like "LFS", every loaded month is
appended to one shared database (LFS_HIST/LFS_HIST.duckdb),
so the whole period can be queried as one table.
refresh = "auto" loads every month not yet present. French
labels come from the French ODESI deposits.tools/build_lfs_hist_reference.R). Each code gets its most
recent wording, and codes whose meaning changed are curated by hand.
Each month is still checked against its own setup file when it is
loaded.get_lfs_timeline() returns one lazy table spanning
"LFS_HIST" and "LFS", 1976 onward, with a
curated common schema. Variables with identical codes carry the current
labels. LFSSTAT, MARSTAT, CMA,
SCHOOLN, AGYOWNK, the industry groups
(NAICS_18), education (1990 onward) and sex/gender are
recoded to common categories. Hours and wages are in plain units, and
the weight is FINALWT. The two databases stay separate and
are attached read-only, so the timeline never takes or waits for a write
lock. The mappings ship in inst/extdata/lfs_timeline/
(tools/build_lfs_timeline_reference.R).
refresh = "auto" first brings both series up to date, so an
analysis script that calls
get_lfs_timeline(refresh = "auto") always picks up newly
released LFS months."LFS_HIST", 50 years of unemployment and participation
rates by gender, wages by CMA, and caveats for working across eras.label_pumf_columns(),
pumf_metadata(), list_pumf_cache(),
remove_pumf_cache() and
open_pumf_documentation() handle both series. LFS behaviour
is unchanged.PUMF data can now be loaded from the Borealis Dataverse, which
hosts the ODESI collection of Statistics Canada PUMFs. Statistics Canada
stays the primary source. The 1971, 1976, 1981 and 1986 Census PUMFs,
which StatCan distributes only by EFT, are now downloaded from Borealis
automatically — get_pumf("Census", "1971") works out of the
box. A deposited EFT bundle is still preferred when present; add
"eft" or "borealis" to the version to choose
explicitly. The Borealis copies carry English labels only. For 1971 they
are also more accurate than the EFT text files, whose negative household
incomes use a sign overpunch the fixed-width reader does not
decode.
Any other Borealis PUMF dataset can be loaded with
get_pumf(series, version, borealis = "doi:..."). New
list_borealis_pumf_catalogue() browses the collection
(cached, and persisted to the cache directory) and
list_borealis_pumf_files() lists a dataset’s files. The
catalogue’s statcan column marks datasets that Statistics
Canada also posts for direct download, together with the matching
StatCan title. Prefer StatCan’s copy for these, since the Borealis
re-deposits can carry transcription errors.
get_pumf(borealis =) warns when asked for such a dataset.
Setting BOREALIS_DATAVERSE_KEY gives access to restricted
files.
Registry entries accept a borealis field
(list(doi =, files =)), also via
pumf_registry_entry().
Truncated labels are now repaired from the survey’s user
guide. Statistics Canada’s shipped command files routinely
carry damaged value and variable labels — hard cuts at 60 characters,
dropped leading text, dropped interior text. The damage is upstream of
the flavour-specific renderers (the SAS, SPSS and Stata copies of a file
agree byte for byte), and it is quiet: codes and frequencies are
correct, only the human-readable label is wrong. A ninth metadata
parser, parse_pdf_freq_codebook(), reads the
data-dictionary appendix of a PUMF user guide (GSS cycles, SGVP, PALS,
SFS, Time Use), which carries the full text.
Trusting a PDF scrape over a machine-readable command file would
normally be a bad trade. What makes it a good one here is that this
appendix prints the frequency of every code, so the
parse is reconciled against the actual data file before any of it is
believed, and a label is replaced only where the guide’s text
demonstrably extends the command file’s — a strict superstring,
or a subsequence sharing a long anchor ("Single-ded house"
→ "Single-detached house"). For GSS Cycle 16 this repairs
2,865 labels across the four modules with no variable contradicting the
data.
A repair additionally requires evidence that the label it replaces was damaged. Some guides print the full question wording where the command file carries a hand-written short label (“How many hours do you work per week” against “How many hours do you (does ….) usually work per week?”); these are different fields, not a truncation, and the abbreviation is often a subsequence of the question, so the text-shape test alone would rewrite good labels into questions. A hard cut leaves a spike of labels at a fixed ceiling — GSS Cycle 16 has 1,665 of 1,860 variable labels at 59–60 characters against 42 in the six lengths below — while a hand-abbreviated set thins out towards its longest entry. Labels are only repaired where that ceiling exists and the label sits at it; everything else is flagged.
Dropped leading text leaves a short label rather than one at a ceiling, so it carries its own signature: what survives is a strict suffix of the guide’s text (“relative in a family farm or business?”, “les réserves indiennes)”). Two things that are not damage produce the same shape — a guide that prefixes an editorial note onto a label the command file has in full (SGVP 2007’s “Grouped variable: Age group”), and a guide leaking its own field header into the text (“Longueur : 2 Age du répondant …”). Both are rejected by looking at the dropped text rather than at what survived: StatCan writes these as “Key: value”, while text lost to truncation is running prose. That distinction is what lets the mid-list case be repaired — GSS Cycle 16’s value label “Co-worker of respondent and Other relatives)”, which is really the tail of “Other (Do not include organizations here) (Includes …)” and reads as a category about co-workers, starts with a capital exactly as an intact label would. Together these take SGVP from 35 repairs to 1 and PALS 2006 from 245 to 100, while GSS Cycle 16 keeps 2,860 of 2,865.
The guide is also checked as a document before any of it is used, against two independent channels: whether its printed counts reproduce a tabulation of the data, and whether its printed field positions reproduce the command file’s layout. A guide failing both is the wrong document and is discarded whole. A release shipping both its original and revised user guide (PALS 2006) is disambiguated the same way — the two describe different field positions, and only the layout tells them apart. Where the positions agree but the counts do not, the guide’s frequencies were simply tabulated on another base (PALS 2006 computes its over the disability sub-population) and are treated as absent rather than as contradiction.
Nothing is repaired silently. New
pumf_label_repairs(tbl) returns every divergence found —
repaired, filled, or merely flagged — with both texts, the reason, and
the variable’s validation status; new
pumf_freq_validation(tbl) reports per variable whether the
guide’s frequencies reconciled. Substantive disagreements (where the
guide and the command file say different things rather than one being a
truncation of the other) are always flagged rather than applied. Set
options(canpumf.pdf_crosscheck = FALSE) to skip the
step.
The guide’s frequency tables are read off the number column
nearest the FREQ header word rather than by walking right
from it. The columns are right-aligned but pdftools
reconstructs them with a few characters of drift, so walking out stopped
at a thousands comma (reading 9,520 as 9) and
never reached a value printed further right than its neighbours (reading
a bare 0 as absent). A code row’s label is also now
optional, so a 0–10 scale that labels only its endpoints keeps the
counts for the nine bare codes in between. Together these take the GSS
Cycle 26 guide from 4 contradicted variables to none across all
610.
Codes the guide documents but the command file never declared are
reported, never injected — that stays a registry
codes_supplement decision. The report covers only variables
the command file treats as categorical: where it declares no codes the
variable is continuous, and the guide’s zero-value rows (“No hours”,
“None”, “Aucun don”) label a valid numeric zero rather than a code the
command file forgot.
The Canadian Health Survey on Seniors (CHSS,
2019-2020) is now supported and directly downloadable:
get_pumf("CHSS", "2019-2020"). The survey ships 1000
bootstrap replicate weights, joined onto the main table like the other
BSW surveys.
The Participation and Activity Limitation Survey
(PALS, 2001 and 2006) is now supported and directly downloadable:
get_pumf("PALS", "2001"). Both editions ship one archive
holding a complete English and French copy of the release; the French
command file is paired automatically and supplies the French
labels.
PALS 2001 ships no flat data file — only the SAS dataset the flat
file would have been built from — so Stage 3 now reads
.sas7bdat data with haven when that is the file the
registry selects. Its coded numeric columns are rendered back to their
code strings so the usual label mapping applies unchanged.
The SAS command-file parser now understands quoted character
codes in PROC FORMAT ("01" = "...", as SAS
datasets with character columns require) and the French phrasing of
StatCan’s variable/format association comment
(/* $FMT s'applique à: VAR1 VAR2 */).
New data_fixups field rename_regex
rewrites many column names at once (c("^A" = "")), for
releases whose data file decorates the documented variable names
wholesale — the PALS 2001 SAS dataset ships StatCan’s
collection names, which prefix 632 of its 758 columns with an
“A”. A rewrite is applied only where it lands on a name the metadata
declares and the current name is not itself declared, so it cannot
collide with a correctly-named column.
New data_fixups field missing_codes
blanks a discrete set of per-variable missing codes, for variables whose
sentinels do not form one contiguous range and which a single
missing_low/missing_high pair therefore cannot
express. PALS 2006 AUDE_Q02 (hours usually worked) declares
−5/−6/−7 below and 998/999 above the valid 1–97 hours, so the derived
range would have blanked the whole column.
New registry field download_format pins which format
bundle to fetch when Statistics Canada offers the same edition as
several downloads (CSV / SAS / TXT). It is needed when only one bundle
carries the command files the metadata parsers depend on — the CHSS CSV
zip ships the data alone, while the TXT zip additionally carries the
SPSS layout cards. The field is also accepted by
pumf_registry_entry() for user-supplied entries.
The SAS @position INPUT-card parser now understands
the indexed-array shorthand StatCan uses for bootstrap-weight cards
(@28 (BSW1-BSW1000) (1000* 7.2)), expanding it into one
layout row per weight. Bootstrap-weight command files are also now found
when they sit outside the survey’s SPSS card directory and are not named
layout* (CHSS ships Layout_Cards/bsw_i.sas);
SAS cards are preferred over their companion .sps, whose
column specs are sometimes left implicit.
Fixed-width bootstrap-weight files are now read with the decimal
point implied by the card’s w.d informat, matching SAS/SPSS
semantics — without this, CHSS replicate weights would have been 100
times too large. The correction is applied before the missing-value
range (which documentation states in display units) and only where the
raw field carries no explicit ..
duckplyr is no longer a dependency. curl
and jsonlite are new in Imports, for the Borealis API.Labelled non-response codes of numeric variables are now set to
NA even when the command file declares no
MISSING VALUES for them. Before, only a declared range, or
the range derived for force_numeric variables, removed
them, so values such as GSS Cycle 21 AGE_DIV_MA1 999.7
(“Not asked”), Cycle 25 CHDCARE_*_COST 9999.97–9999.99 and
the Cycle 21 and 26 health utility index HLTH_UTIL_INDEX
7/9 (“Not asked”, “Don’t know”; valid range −0.31 to 1) stayed in as
real numbers. Stage 3 now takes every code whose English or French label
is a true-missing label and blanks it as a discrete code, so valid
values that fall between sentinels are kept. Labels with a qualifier
also count (“NOT APPLICABLE(DOES NOT DRIVE)”, GSS Cycle 8
D11; “Non demandé - aucun enfant dans le ménage”, Cycle 24
AGECHRYC). Zero labels (“None”) and composite labels (“zero
income, not applicable”) are left as values. Rebuild with
refresh = TRUE: GSS Cycles 8, 17, 21, 24, 25 and
26.
GSS Cycle 17 (2003) no longer forces 236 categorical variables to
numeric. Its force_numeric list covered almost every
labelled variable, so SEX, PRV,
YRARRI, EDU5, the Likert items and the rest
arrived as bare numbers instead of labelled factors. Only the six
count/age variables with a top-code label (AGECHRYC,
OMA_Q110, MAR_Q161, WKWEHR,
WKWEHOHR, MAR_Q315) are still forced.
force_numeric can no longer turn a fully labelled
variable into numbers. Labels are strong evidence of a category, so the
only legitimate use of the override is a count, age or amount variable
whose data is mostly unlabelled, with labels only on a top code or on
sentinels. Stage 3 now ignores the override for any variable whose every
data value is labelled. Besides Cycle 17, this restores GSS Cycle 12
DDAY (Sunday–Saturday), GSS Cycle 24
TIMECR/TIMENS (“Zero Yes codes”…) and 1971
Census SUBSAMPL in the individual and family files
(ONE–FIVE) as factors. The dead Cycle 12 and 24 entries were removed
from the registry. Rebuild with refresh = TRUE: GSS Cycles
12 and 24, and the 1971 Census individual and family files.
Fixed-width main data files are now also read with the decimals
their command file implies — a DATA LIST ( 4 )
or SAS w.d informat — where the raw field carries no
explicit .. The older cards pad the parentheses
(WGHTFNL 6 - 14 ( 4 )), which the parser did not
recognise, so the weights of GSS Cycle 8 (1993) and Cycle 9 (1994) were
10,000 times too large and the 1981 Census households
FAMWGT (EFT copy) 100 times too large. Display
FORMATS decimals do not change the stored value and are not
applied. Layout decimals are recorded in a new optional
decimals column of layout.csv; caches written
before it read as having none.
GSS Cycle 10 (1995) and Cycle 15 (2001) read their Main data file
with the Child file’s layout, so every column past the first few was
misaligned. Both now select the Main command files
(layout_mask), and their force_numeric
overrides were redone for the Main-file variables.
SPSS MISSING VALUES lists of reserved codes with a
gap (( 96,97,99 ), ( 9996,9997,9999 )) are
read as the full band, and an empty first slot
(( ,995 THRU 999 )) no longer drops the lower bound. GSS
Cycles 8 and 10 kept codes such as 97/99 “Not applicable/Not stated” as
real values in numeric columns.
SPSS MISSING VALUES statements declaring several
variables on one line (INCWAGES (0) SELF (0) .) now
record every declaration, not just the first, and a list of consecutive
integers (998,999, 8, 7) is read as the full
range rather than its first value. The range change only affects
variables typed numeric, and only by widening sentinel ranges already
declared as missing (e.g. 1991/1996 Census AGEF 98 “Not
available” alongside 99).
Command files with \r\r\n line endings, doubled
apostrophes ('Person 1''s son'), HTML entities in labels
(Yukon & NWT) and value labels on the
variable-header line (HHTYPE 1 "1 FMLY …") are now parsed
correctly. These affected the older Census command files; rebuild those
with refresh = TRUE to pick up the corrected
labels.
Census downloads resolve again after Statistics Canada moved its
Census PUMF index page. The emptied scrape was not recognised as a
failure, so list_canpumf_collection() lost its 1991–2021
Census rows and warned no non-missing arguments to min. The
Census list now falls back to the StatCan catalogue (every edition now
lives under 98m0001x/2023001/), and the hard-coded
last-resort URLs point there too.
get_pumf() no longer takes a write lock on a pure
cache hit (#18). The non-LFS read path routed through
get_pumf_connection(), which always opened the DuckDB
read-write before the tbl was reopened read-only — so reading an
already-built survey from a second R process (typically a notebook
render racing the interactive session that still held connections open)
failed with a “Conflicting lock is held” error even though concurrent
read-only access is perfectly legal. A write connection now exists only
inside the Stage-3 builder while a build or refresh actually writes, and
is closed there; everything handed to the user is read-only unless
read_only = FALSE is requested. The already-built check
likewise no longer shuts down the shared in-process DuckDB instance, so
requesting e.g. the French table while the English tbl is open leaves
the open tbl undisturbed.
add_bootstrap_weights() and
remove_bootstrap_weights() — the genuine write paths — now
diagnose lock conflicts up front with an actionable message saying what
holds the file and to release it with close_pumf(), instead
of surfacing duckdb’s raw lock/read-only error from the first write
(#18).
SPSS string continuations ('text' + 'more', which
StatCan uses to keep a long label inside the file’s line width) are now
joined in all four combinations of quote character and line break. Only
the single-quoted, line-broken form was handled, so the tail of a
continued label was dropped and what survived was cut mid-word — Census
2021 SSGRAD arrived as “Scolarité : Diplôme d’études
secondaires ou attestation d’éq”, indistinguishable from the upstream
truncation the new user-guide cross-check exists to repair. Census 2021
alone ships all three of the unhandled forms (70 labels in the French
individuals file).
A user-guide variable printed without a
frequency table no longer swallows the rest of the document as its
label. The label is the free text between the block header and the
table, so where there is no table the extraction ran to the end of the
guide: GSS Cycle 24’s WTSBS_001 (bootstrap weight #1) came
out as 78,014 characters of appendix and table of contents, which the
repair pass then wrote over a sound command-file label. The label now
also ends at the block’s own closing rule or its
Coverage:/Source:/Format: lines.
Only tableless blocks are affected — across the cached guides this
changes 3 labels in GSS Cycle 24, 2 in SGVP 2007 (including a
19,385-character WTPP), 1 in PALS 2006 and none at all in
GSS Cycle 16.
A guide row whose label reaches into the number column is now
read. A long label pushes the frequency past the FREQ
anchor and sends the weighted count to the next line, so the row got no
frequency at all and the orphaned weighted count was appended to the
label (GSS Cycle 24’s Episode guide, SACT1 code 15:
"Domestic work (meal prep and cleanup, cleaning, laundry) 4,255"
with "6,759,111" alone below it). A single
whitespace-preceded number starting at or after the anchor is now taken
as the frequency, and a continuation line that is nothing but a number
is no longer treated as label text. Where the label is printed flush
against its counts
("…cassette tapes or records3,4417,790,477") the two counts
cannot be separated, so the frequency stays unknown — but the digits are
cut off the label rather than left in it.
An unreadable frequency no longer aborts metadata parsing.
Comparing counts against it made all() return
NA and the if that followed errored, taking
the whole Stage 2 run down; the block is now reported
unchecked, which withholds nothing, since repairs are
barred only by an outright mismatch. The cross-check runs
only on a fresh parse, so this surfaced only when re-parsing a cached
survey.
SHS 2017 and 2019 command files are read as UTF-8 (2021 and 2023 are not), so the CP1252 default turned every accented French label into mojibake — 671 labels across the four files, e.g. “Poids d’enquête” arriving as “Poids d’enquête”.
Census 2021 individuals variable labels no longer show “–” in
place of an en-dash (#22). The English command files are valid UTF-8 but
were themselves written with the dash double-encoded, which no
metadata_encoding can undo, so 10 labels such as
School attendance – Detailed came through garbled. Stage
2 now repairs double-encoded UTF-8 in the merged metadata. The repair
only replaces a character sequence that decodes to valid UTF-8, so
genuine accents are left alone. Rebuild with
refresh = TRUE.
The French “valid skip” sentinel label
(Enchaînement valide) is now recognised. The alternative
had been added as a bare stem inside an anchored pattern, so it only
ever matched a label that was literally Enchaîn — a French
build could therefore keep a continuous variable categorical (and blank
its real values) where the English build read it correctly.
Sentinel labels containing accented characters are now matched.
The label patterns relied on \w, which PCRE restricts to
ASCII even on UTF-8 input, so a French label ended at its first accent:
Aucune séparation avant le divorce ou l'annulation failed
where the English
No separation prior to divorce or annulment matched,
classifying the variable numeric in eng but categorical in
fra (GSS Cycle 21
AGE_SEP_MA3/AGE_SEP_MA4). An elided article
(l'annulation) and a trailing sentence period present in
only one language (GSS Cycle 24) split the two builds the same way.
Accented capitals in shouted labels (NON DÉCLARÉ) now fold
correctly too. Across every cached survey this changes the
classification of 35 variables, all of them in GSS, and all now
identical in both languages.
list_statcan_pumf_catalogue() crawls the
live Statistics Canada “Public use microdata” listing and returns one
row per discovered survey edition (catalogue_id,
Title, edition, format,
url, product_url) — a discovery counterpart to
the curated list_canpumf_collection() that picks up newly
released PUMFs automatically. Editions offered in several formats
collapse to a single preferred row (CSV / flat text first), but
genuinely distinct surveys or file-types that share a reference year are
kept as separate rows (e.g. the GSS cycle and the Giving/Volunteering
survey both released in 2007, or the census
individual/family/household/hierarchical files for one year). Surveys
distributed only by Electronic File Transfer report
url = "(EFT)".list_statcan_pumf_catalogue() caches its result for the
duration of the R session and reuses it on subsequent calls with the
same arguments. Pass refresh = TRUE to re-scrape the live
catalogue and replace the cached result, e.g. to pick up a newly
released survey mid-session.cenNN /
nhsNN filename prefix (the 2011 cycle shipped as the
National Household Survey) and ind / fam /
hous / hier file type into canonical
"YYYY (individuals)"-style strings matching
list_canpumf_collection(). This is forward-compatible: the
2026 census PUMF will resolve automatically once released.list_statcan_pumf_catalogue() now returns a
SeriesTitle column (the plain-language series name matching
the acronym) alongside an edition-specific Title. For
umbrella products whose catalogue title is only the series name
(e.g. the consolidated General Social Survey, or a census year’s
individuals/hierarchical pair) the Title is synthesised as
"<series> — <edition>", where the structural
edition descriptor disambiguates colliding reference years
("General Social Survey — Cycle 16 (2002)",
"Census of Population — 2021 (individuals)"); per-edition
products keep Statistics Canada’s own title.get_pumf() now resolves download URLs from the scraped
catalogue first for the series the crawler covers (GSS, SHS, SFS, CPSS,
CIS, CHS, ITS, CCAHS), so a newly released edition is downloadable
without a package update. Series the crawler deliberately does not cover
— LFS and Census (which keep their dedicated paths) and the
Giving/Volunteering surveys (SGVP, which Statistics Canada
ships under reused zip names the umbrella crawl cannot disambiguate) —
continue to resolve through the curated
list_canpumf_collection(). URL resolution never triggers a
live crawl; it reads the cached catalogue.inst/extdata/pumf_catalogue.rds). It is the terminal,
always-available fallback for both URL resolution and
list_statcan_pumf_catalogue(): a freshly installed package
with no user cache and no network still resolves every supported
survey’s download URL, so a change to the Statistics Canada website
cannot silently break get_pumf() between releases. The
shipped snapshot is regenerated at each release.get_pumf(), get_pumf_connection() and
pumf_metadata() now fail gracefully when Statistics Canada
is unreachable: a download failure no longer raises an error but instead
emits an informative message and returns NULL.
list_available_lfs_pumf_versions() likewise returns an
empty result with a warning rather than erroring, matching the existing
behaviour of list_canpumf_collection() and
list_statcan_pumf_catalogue().close_pumf(NULL) is now a no-op, so it can be called
unconditionally on a get_pumf() result that may be
NULL.options(canpumf.cache_path = ) is not set, the
package now notes this once when attached and again on the first
download, explaining that data is written to a temporary directory (and
discarded at the end of the session) and how to configure a persistent
cache. The underlying behaviour is unchanged — without a cache path,
data is stored in tempdir() for the session.Data - Données/
folder) now extract correctly on Linux and Windows. Previously
utils::unzip() either errored with “invalid multibyte
string” (Windows) or silently dropped the affected files under a
non-UTF-8 locale (Linux), so the survey failed to import with “No
parseable metadata files found”. Extraction now uses
zip::unzip() as the primary, locale-agnostic extractor on
every platform (with the macOS
ditto/system-unzip chain retained as a
fallback for newer ZIP compression variants), giving uniform
cross-platform behaviour. zip is a new dependency.get_pumf() returns the survey’s primary
(respondent-level) module and emits a one-time message listing the
available sibling modules;
pumf_module(tbl, "<module>") opens a sibling on the
same connection so the two are joinable, and announces
the shared join key. Each module’s join key is recorded in the registry
(module_key) so it never has to be guessed (it varies:
RECID, PUMFID, MICRO_ID,
CASEID, IDNUM). Converted surveys include GSS
cycle 16 / “Aging and Social Support” 2002 (MAIN + CG4 + CG6 + CR), GSS
Time Use 1998/2010/2015/2022 (Main + Episode), the Survey of Household
Spending 2017 (Interview + Diary, each with its own bootstrap weights),
and the Giving/Volunteering/Participating cycles 1997–2010 (MAIN +
GS/VD/GIVE/VOLNTR).close_pumf() now also accepts a DuckDB connection
returned by get_pumf_connection(), closing it directly, in
addition to a lazy dplyr::tbl() returned by
get_pumf().parse_pdf_codebook() metadata parser for StatCan
bilingual PDF frequency codebooks. This recovers variable and
value labels for surveys whose only machine-readable companion is the
data file — notably CPSS cycle 1, which (unlike CPSS 2–6) ships no
variables.csv. CPSS 1 now imports with full bilingual
labels (parity with the other cycles) when pdftools is
installed. Like the existing PDF data-dictionary parser, it is a label
fallback that only fires when no command file or codebook CSV is found,
and requires pdftools (Suggests).pumf_module(), join them inside DuckDB, and use
get_pumf_connection() / close_pumf()
directly.get_pumf("LFS") (and other calls) no longer trigger
spurious RStudio “Error in dbSendQuery(…)” Connections-pane popups.
Transient internal DuckDB connections (status checks, write phases, BSW
edits) are no longer registered in the RStudio Connections pane; only
the final connection returned to the user is registered.add_bootstrap_weights() on an in-memory
data.frame/tibble that already has replicate
columns now extends the existing set (generating only the additional
replicates) instead of regenerating a full set and producing duplicate
column names. This matches the DuckDB-backed behaviour.add_bootstrap_weights() now handles rows added to a
survey table that already has bootstrap weights correctly. Previously it
generated replicates for the new rows in isolation (resampling only
among the new rows), which is statistically wrong. It now deletes and
regenerates the affected weights: every row when unstratified, or only
the strata that gained rows when strata_cols are in effect
(complete strata keep their existing weights).R CMD check) list.files()
selected the Main module’s SAS PROC FORMAT, which injected
categorical codes onto continuous clock-time, duration, decimal-hour and
birth-year variables; these are now declared force_numeric
so their values are preserved. In addition,
merge_metadata() no longer warns about label conflicts that
arise solely from lossy supplement parsers (SAS labels, PDF
dictionary/codebook) — authoritative-source conflicts still warn.These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.