Standardizes data types across columns based on common patterns (e.g., columns ending in "_id" become integers, columns with "date" become dates).
Arguments
- data
Data frame or tibble
- type_rules
List of named character vectors defining type conversion rules. If NULL, applies default heuristics.
Details
Default type conversions:
Columns named "*_id": convert to integer
Columns named "*_date": convert to date (ISO format assumed)
Columns named "*_count": convert to integer
Columns containing "flag" or "indicator": convert to logical
A conversion is only applied if it preserves every non-missing value. A
column that matches a rule but cannot be coerced without introducing NA
(for example a character database_id) is left as-is and reported.