Skip to contents

This function exports a database (fully or partially) to a new file without modifying the original database. It's useful for versioning, sharing, or creating targeted subsets of your boilerplate content.

Usage

boilerplate_export(
  db,
  output_file,
  select_elements = NULL,
  data_path = NULL,
  confirm = TRUE,
  create_dirs = FALSE,
  quiet = FALSE
)

Arguments

db

List. The database to export from. Can be a single category database or a unified database with multiple categories.

output_file

Character. Name of the output file.

select_elements

Character vector. Optional paths to select in dot notation. Use "" for wildcard selection (e.g., "statistical." selects all statistical methods). If NULL or empty (default), exports the entire database.

data_path

Character. Base path for data directory. If NULL (default), uses here::here("boilerplate", "data").

confirm

Logical. If TRUE, asks for confirmation before overwriting. Default is TRUE.

create_dirs

Logical. If TRUE, creates directories that don't exist. Default is FALSE.

quiet

Logical. If TRUE, suppresses all CLI alerts. Default is FALSE.

Value

Invisibly returns the path to the saved file if successful, or NULL if cancelled.

Examples

if (FALSE) { # \dontrun{
# Export the entire database (versioning)
unified_db <- boilerplate_import()
boilerplate_export(
  unified_db,
  output_file = "boilerplate_backup_20250405.rds"
)

# Export selected elements from a unified database (sharing specific parts)
unified_db <- boilerplate_import()
boilerplate_export(
  unified_db,
  output_file = "causal_methods_subset.rds",
  select_elements = c("methods.statistical.*", "results.main_effect")
)

# Export selected elements from a single category (creating a subset)
methods_db <- boilerplate_import("methods")
boilerplate_export(
  methods_db,
  output_file = "causal_methods.rds",
  select_elements = c("statistical.longitudinal.*", "causal_assumptions")
)
} # }