Skip to contents

Resolution order:

  1. Local RDS/CSV files in standard project locations

  2. SQLite cache (data/cache/morie.db)

  3. CKAN API fetch (requires internet)

Usage

morie_load_cpads(db_path = NULL, use_ckan = TRUE, con = NULL)

Arguments

db_path

Optional path to a SQLite/DuckDB file (default backend).

use_ckan

Logical; if TRUE and data not found locally or in cache, attempt to fetch from the CKAN API.

con

Optional pre-opened DBI connection (overrides db_path).

Value

A data.frame with canonical CPADS columns.

Examples

# Local-first and offline: use_ckan = FALSE consults the bundled copy
# and the local cache only, and errors when neither is present.
cpads <- try(morie_load_cpads(use_ckan = FALSE), silent = TRUE)
if (!inherits(cpads, "try-error")) head(cpads)
if (FALSE) { # \dontrun{
# The live CKAN fetch pages through the datastore; it ran for over ten
# minutes in the docs build, so it is shown rather than executed.
cpads <- morie_load_cpads(use_ckan = TRUE)
if (!is.null(cpads)) head(cpads)
} # }