
Initialise a Specific Boilerplate Database Category
Source:R/init-functions.R
boilerplate_init_category.Rd
This function initialises or updates a specific boilerplate database category with default values.
Usage
boilerplate_init_category(
category,
merge_strategy = c("keep_existing", "merge_recursive", "overwrite_all"),
data_path = NULL,
quiet = FALSE,
dry_run = FALSE,
create_dirs = FALSE,
confirm = TRUE,
create_empty = TRUE
)
Arguments
- category
Character. Category to initialise. Options include "measures", "methods", "results", "discussion", "appendix", "template".
- merge_strategy
Character. How to merge with existing database: "keep_existing", "merge_recursive", or "overwrite_all".
- data_path
Character. Base path for data directory. If NULL (default), uses here::here("boilerplate", "data").
- quiet
Logical. If TRUE, suppresses all CLI alerts. Default is FALSE.
- dry_run
Logical. If TRUE, simulates the operation without writing files. Default is FALSE.
- create_dirs
Logical. If TRUE, creates directories that don't exist. Default is FALSE.
- confirm
Logical. If TRUE, asks for confirmation before making changes. Default is TRUE.
- create_empty
Logical. If TRUE, creates empty database structures with just the template headings. Default is TRUE. Set to FALSE to use default content.
Examples
# Create a temporary directory for examples
temp_dir <- tempdir()
data_path <- file.path(temp_dir, "boilerplate_category_example", "data")
# Initialise the methods database with empty structure
boilerplate_init_category(
"methods",
data_path = data_path,
create_dirs = TRUE,
create_empty = TRUE,
confirm = FALSE,
quiet = TRUE
)
#> [1] TRUE
# Check the created file
methods_file <- file.path(data_path, "methods_db.rds")
file.exists(methods_file)
#> [1] TRUE
# Initialise measures database with default content
boilerplate_init_category(
category = "measures",
merge_strategy = "merge_recursive",
data_path = data_path,
create_dirs = TRUE,
create_empty = FALSE,
confirm = FALSE,
quiet = TRUE
)
#> [1] TRUE
# Load and inspect the measures database
measures_db <- readRDS(file.path(data_path, "measures_db.rds"))
names(measures_db)
#> [1] "anxiety" "depression" "alcohol_frequency"
#> [4] "life_satisfaction"
# Clean up
unlink(file.path(temp_dir, "boilerplate_category_example"), recursive = TRUE)