Build a complete col_map with dictionary inference and alias materialization
Source:R/utils_helpers.R
dot-hm_build_col_map.RdCombines three previously separate steps into one call:
User-supplied entries in
col_mapare treated as authoritative Layer 0 seeds – they are never overwritten.hm_col_report()fills any remaining unmatched keys via the full synonym dictionary (exact -> case-insensitive -> contains layers).Literal-name fallback: if a key in
keysstill has no match, but the key name exists verbatim as a column indata, it is used directly.Materialization: for every mapped key
kwherecol_map[[k]] != kandkis not already a column indata, a copydata[[k]] <- data[[col_map[[k]]]]is added. This ensures that downstream pre-computation helpers (which checknames(data)for dependency names) and theircompute()closures (which use literal key names) both resolve correctly even when the physical column has a non-standard name.
Arguments
- data
The data.frame being analysed (modified locally; original is not altered outside the function call).
- col_map
Named list of user-supplied key -> column-name mappings, or
NULLfor full auto-inference.- keys
Character vector of short internal keys to resolve.
- fn
Calling function name string (for messages).
Value
A list with four elements:
- data
The (possibly augmented) data.frame.
- col_map
Complete named list of key -> resolved column name.
- user_keys
Keys that were explicitly provided in the original
col_mapargument.- inferred_keys
Keys resolved by dictionary inference or literal fallback (i.e., not in
user_keys).