Reads a filled-in column mapping template (Excel or CSV) and returns a named list suitable for passing to clean_steps_data(). The mapping file should have at least two columns: one with the standard variable name (column A) and one with the user's column name (column C in the template, or the third column).

read_column_mapping(path, data = NULL)

Arguments

path

Path to the filled mapping file (.xlsx or .csv).

data

Optional data frame. If provided, the function validates that every mapped column actually exists in the data.

Value

A named list where names are standard variable identifiers (e.g. "age", "sbp1") and values are the corresponding column names in the user's dataset. Unmapped variables are set to NULL.

Details

This function is the manual alternative to detect_steps_columns(). Use it when your dataset has non-standard variable names that auto-detection cannot resolve.

A blank template can be obtained from system.file("templates", "column_mapping_template.xlsx", package = "stepssurvey") or downloaded from the Shiny app.

The function ignores domain-header rows (rows where column A is all-caps with no entry in column C) and skips any row where the user's column name is blank.

Examples

if (FALSE) { # \dontrun{
  cols <- read_column_mapping("my_mapping.xlsx")
  raw  <- import_steps_data("survey.dta")
  clean <- clean_steps_data(raw, cols)
} # }