This function cleans the columns of a `DB` object, transforming choice fields into factors and ensuring numeric columns are set correctly for table processing or plotting (e.g., using `table1`). It handles the transformation of missing values and optional removal of certain codes based on user input.
Arguments
- DB
A validated `DB` object containing REDCap project data and settings. Generated using load_DB or setup_DB
- drop_blanks
Logical. If TRUE, will drop choice fields with zero occurrences (n = 0). Default is FALSE.
- other_drops
A list of additional fields or choices to drop from the data. Defaults to NULL.
Details
The function works by cleaning up the data frame list (`DB$data`) according to the metadata (`DB$metadata$fields`). It converts choice fields into factors, numeric fields are treated appropriately, and any unwanted or missing codes can be dropped based on the parameters provided. The function also ensures that the data is only cleaned once by checking the internal `is_clean` flag.