Data Management
Check Variable Names Without Silently Changing Their Meaning
Treat names as identifiers
A variable name links a column to its dictionary entry, analysis code, and output. Renaming it can break that link even when the new name looks cleaner. Begin with a complete ordered list of original column names from the actual export, including duplicate names if the format permits them.
Keep a readable variable label separate from the machine-facing name. A short identifier such as bp_sys_baseline can be useful, but its definition still needs measurement units, timing, and population. Name quality and scientific meaning are different checks that should support each other.
Define the convention before applying it
Choose a convention appropriate for the tools that will receive the data. State permitted characters, capitalization, separators, maximum length if relevant, and treatment of reserved words. A conservative project convention may be more restrictive than the software's actual syntax; describe it as a project rule rather than a universal technical requirement.
The official R make.names documentation shows how software can transform names and make them syntactically valid. Such automatic repair can create names that differ from the original export, so verify the mapping rather than assuming a successful import preserved every identifier.
Test fictional collisions
Imagine an export containing “Visit Date”, “visit-date”, and “visit_date”. A rule that lowercases names and changes spaces and hyphens to underscores would map all three to visit_date. That collision needs a decision based on the field definitions; adding arbitrary suffixes might conceal that two columns refer to different visits.
Also test exact duplicates, leading or trailing spaces, empty names, names beginning with numbers, and case-only differences. The variable-name checker can flag naming issues in a list of synthetic field names. Its convention permits 1–32 ASCII characters, starting with a lowercase letter and continuing with lowercase letters, digits, or underscores. It does not rename fields or check every language's reserved words. Its checks cannot infer whether two columns measure the same quantity.
Rename with an explicit map
Create a two-column original-to-final mapping, with a reason and dictionary reference for every changed name. Require unique final names under the target system's comparison rules. If the source contains exact duplicate headers, preserve their original column positions or other identifiers so the mapping is unambiguous.
Apply the map reproducibly to a derived dataset. Update analysis scripts and documentation together, then compare the column count, order where relevant, and values before and after the change. Renaming should not unexpectedly alter the underlying observations or delete a column.
Finish by checking a fresh import into the intended analysis software. Confirm that it does not apply another silent repair or truncate names into new collisions. Store the mapping with the data dictionary audit and record the dataset version. A colleague should be able to trace any displayed analysis variable back to the exact original field without guessing which naming rule was applied.
Source checked on 1 November 2026; collision examples are fictional.