Skip to contents

Resolves a CPADS analysis frame from one of three sources:

Usage

morie_datasets_cpads(
  offline = TRUE,
  mode = c("datastore_search", "csv"),
  limit = NULL,
  q = NULL
)

Arguments

offline

Logical. TRUE (default) prefers the bundled fixture for fast/CRAN-safe runs; FALSE fetches the live PUMF.

mode

Character; one of "datastore_search" (default; queryable CKAN datastore endpoint, supports limit/q) or "csv" (whole PUMF CSV download). Ignored when offline = TRUE.

limit

Integer or NULL; row cap, forwarded to datastore_search when mode = "datastore_search". NULL returns the datastore default (100 rows).

q

Character or NULL; free-text query forwarded to datastore_search (e.g. q = "title:jones"). Ignored for mode = "csv".

Value

A data.frame carrying every CPADS PUMF column plus morie's canonical analysis aliases (weight, alcohol_past12m, heavy_drinking_30d, ebac_tot, ebac_legal, cannabis_any_use, age_group, gender, province_region, mental_health, physical_health).

Details

  1. A pre-wrangled local RDS at morie_cpads_contract()$expected_wrangled_path (only useful if you've already produced one), OR

  2. the bundled 30-row real PUMF sample at inst/extdata/cpads_pumf_synthetic.csv (when offline = TRUE, the default; carries all 394 raw PUMF columns plus the 11 morie canonical analysis aliases), OR

  3. the live PUMF via the CKAN datastore_search API (default, supports limit/q) or the full PUMF CSV (with mode = "csv"): https://open.canada.ca/data/dataset/736fa9b2-62e4-4e31-aea4-51869605b363/resource/d2639429-c304-45a6-90b3-770562f4d46d/download/cpads-2021-2022-pumf2.csv (when offline = FALSE).

CPADS is open data published by Health Canada / Statistics Canada (Open Government Licence – Canada). Aggregate dashboards at https://health-infobase.canada.ca/substance-use/reports/cpads/; PUMF user guide: https://open.canada.ca/data/dataset/736fa9b2-62e4-4e31-aea4-51869605b363/resource/a078e4c3-a910-4349-b00e-6ea0d31d391d/download/20212022-cpads-pumf-user-guide.pdf. Sister surveys (CSADS, CSUS, CTADS) are at https://health-infobase.canada.ca/substance-use/.

See also

morie_cpads_contract() for the canonical schema + column map; morie_datasets_load_by_key() for catalog-wide dispatch.