Generate Measures Section for Methods
boilerplate_measures.Rd
This function generates a markdown-formatted section describing the measures used in the study. It includes baseline variables if provided, renames measures based on label mappings, and excludes appendix-related sections and color formatting. References are formatted based on their content.
Usage
boilerplate_measures(
baseline_vars = NULL,
exposure_var,
outcome_vars,
measure_data,
label_mappings = NULL,
print_waves = FALSE
)
Arguments
- baseline_vars
A character vector specifying the names of baseline variables. Optional.
- exposure_var
A character string specifying the name of the exposure variable.
- outcome_vars
A named list of character vectors specifying the outcome variables by domain.
- measure_data
A list containing information about each measure.
- label_mappings
An optional named list where each element is a named vector for renaming variables.
- print_waves
A logical value indicating whether to print wave information. Default is FALSE.
Examples
if (FALSE) { # \dontrun{
# Define baseline variables
baseline_vars <- c("age", "gender", "education_level")
# Define outcomes by domain
outcomes_health <- c("hlth_bmi", "hlth_sleep_hours")
outcomes_psychological <- c("kessler_latent_anxiety", "rumination")
all_outcomes <- list(
health = outcomes_health,
psychological = outcomes_psychological
)
# Define the exposure variable
exposure_var <- "religion_church"
# Define label mappings
label_mappings <- list(
baseline = var_labels_baseline,
exposure = label_mapping_raw_exposure,
health = label_mapping_raw_health,
psychological = label_mapping_raw_psych
)
# Load your measure_data
measure_data <- readRDS(here::here("boilerplate", "data", "measure_data.rds"))
# Call the function
measures_section <- boilerplate_measures(
baseline_vars = baseline_vars,
exposure_var = exposure_var,
outcome_vars = all_outcomes,
measure_data = measure_data,
label_mappings = label_mappings
)
# Print the generated markdown
cat(measures_section)
} # }