Rename and Validate Dataframe Variables Based on Configuration
handle_variable_names.Rd
This function takes a dataframe and a configuration dictionary of origin variables, checks if specified variables are present, renames them, validates their types, and returns the modified dataframe and a list of missing variable IDs.
Value
A list containing:
- dataframe
The modified dataframe with renamed variables.
- missing_vars
A character vector of variable_ids that were not found in the dataframe.
Examples
# Assuming 'df' is your dataframe and 'origin_variables' is loaded from config.yml
result <- handle_variable_names(df, origin_variables)
#> Error: object 'origin_variables' not found
modified_df <- result$dataframe
#> Error: object 'result' not found
missing_vars <- result$missing_vars
#> Error: object 'result' not found