Skip to contents

Checks if all codelists required by a dataset are in cache. Downloads missing codelists before labeling operations. This prevents apply_labels() from failing on new datasets.

Usage

ensure_codelists(dataset_id, cache_dir = .istatlab_cache_dir(), verbose = TRUE)

Arguments

dataset_id

Character, dataset ID to check

cache_dir

Character, cache directory path. Defaults to the ISTATLAB_CACHE_DIR environment variable, or "meta" if unset.

verbose

Logical, print status messages. Default TRUE

Value

Logical, TRUE if all codelists are available (cached or downloaded)

Examples

if (FALSE) { # \dontrun{
# Ensure codelists before labeling
if (ensure_codelists("534_50")) {
  labeled_data <- apply_labels(raw_data)
}

# Check new dataset
ensure_codelists("150_908", verbose = TRUE)
} # }