Manage Measures in Boilerplate Database (Deprecated)
Source:R/backward-compatibility.R
, R/manage-measures.R
boilerplate_manage_measures.Rd
This function is partially deprecated. For basic list/get operations, please use boilerplate_import("measures") instead. Other functionality is maintained for backward compatibility.
This function manages measures in a boilerplate database, allowing for adding, updating, removing, retrieving, and listing measure entries.
Usage
boilerplate_manage_measures(
action = c("add", "update", "remove", "get", "list", "save"),
name = NULL,
measure = NULL,
db = NULL,
measures_path = NULL,
file_name = NULL,
create_dirs = FALSE,
confirm = TRUE,
dry_run = FALSE,
quiet = FALSE
)
boilerplate_manage_measures(
action = c("add", "update", "remove", "get", "list", "save"),
name = NULL,
measure = NULL,
db = NULL,
measures_path = NULL,
file_name = NULL,
create_dirs = FALSE,
confirm = TRUE,
dry_run = FALSE,
quiet = FALSE
)
Arguments
- action
Character. Action to perform: "add", "update", "remove", "get", "list", or "save".
- name
Character. Name of the measure to manage.
- measure
List. Measure data (for add/update actions).
- db
List. Optional database to use (required for "save", optional for other actions).
- measures_path
Character. Path to the directory where measures database files are stored. If NULL (default), uses the "boilerplate/data/" subdirectory of the current working directory via the here::here() function.
- file_name
Character. Name of the file to save or load (without path). If NULL (default), uses "measures_db.rds". Note: For "save" action, file_name must be explicitly provided.
- create_dirs
Logical. If TRUE, creates directories that don't exist. Default is FALSE.
- confirm
Logical. If TRUE, asks for confirmation before creating directories or modifying files. Default is TRUE.
- dry_run
Logical. If TRUE, simulates the operation without writing files. Default is FALSE.
- quiet
Logical. If TRUE, suppresses all CLI alerts. Default is FALSE.
Value
Depends on the action (see original function documentation).
Depending on the action:
"add", "update", "remove": The modified database (list).
"get": The measure data (list).
"list": The entire database (list).
"save": Invisible NULL (called for side effects).
Examples
if (FALSE) { # \dontrun{
# First, run with dry_run to see what would happen
boilerplate_manage_measures(
action = "list",
measures_path = "path/to/project/data",
dry_run = TRUE
)
# List existing measures
measures_db <- boilerplate_manage_measures(
action = "list",
create_dirs = TRUE,
confirm = TRUE
)
# Add a new measure
measures_db <- boilerplate_manage_measures(
action = "add",
name = "anxiety_gad7",
measure = list(
name = "Generalized Anxiety Disorder Scale (GAD-7)",
description = "Anxiety was measured using the GAD-7 scale.",
reference = "spitzer2006",
waves = "1-3",
keywords = c("anxiety", "mental health", "gad"),
items = list(
"Feeling nervous, anxious, or on edge",
"Not being able to stop or control worrying"
)
)
)
# Get a specific measure
anxiety_measure <- boilerplate_manage_measures(
action = "get",
name = "anxiety_gad7"
)
# Save changes to database with explicit file_name to prevent accidental overwrites
boilerplate_manage_measures(
action = "save",
db = measures_db,
file_name = "my_measures_db.rds",
confirm = TRUE
)
# Remove a measure
measures_db <- boilerplate_manage_measures(
action = "remove",
name = "anxiety_gad7"
)
} # }