Skip to contents

Downloads large bootstrap weight CSVs that are too big to ship with the package. Data is cached in the user cache database for future use.

Usage

morie_download_bootstrap(
  survey = "all",
  limit = 32000L,
  db_path = NULL,
  con = NULL,
  refresh = FALSE
)

Arguments

survey

A bootstrap key of morie_dataset_catalog ("ocs22bt", "ocs24bt", "cu20bt", "cu23bt"), its survey-year name ("csads_2021", "csads_2023", "csus_2019", "csus_2023"), or "all" (default).

limit

Max records per CKAN request (default 32000).

db_path

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

con

Optional pre-opened DBI connection (overrides db_path).

refresh

Download again even when the table is already cached (default FALSE: a cached table is reported and kept).

Value

Invisibly, the number of surveys available (downloaded or already cached).

Examples

# the bootstrap tables and their keys
cat_ <- morie_dataset_catalog()
cat_[cat_$type == "bootstrap", c("key", "name")]
#>        key                      name
#> 6  ocs22bt CSADS 2021-2022 Bootstrap
#> 8  ocs24bt CSADS 2023-2024 Bootstrap
#> 10  cu20bt  CSUS 2019-2020 Bootstrap
#> 12  cu23bt       CSUS 2023 Bootstrap
# \donttest{
# the CSADS 2021 bootstrap weights are 376 MB: fetched once, then read from the cache
if (interactive()) morie_download_bootstrap(survey = "csads_2021")
# }