Automating Data Cleaning Processes in R

Instruction: Demonstrate an auditable R cleaning function for a data frame with unique nonmissing IDs and numeric amounts. Accept finite nonnegative amounts, return missing/invalid amounts separately with reasons, and fail on malformed keys or types. Use IDs 1,2,3,4 with amounts 10,missing,-2,0; discuss testing and model-preprocessing boundaries.

Context: This question evaluates the candidate's proficiency in automating repetitive data cleaning tasks in R, improving efficiency and consistency.

Updated

Official answer available

Read the opening below, then unlock the full answer and practical guidance.

Automate an explicit data contract, not automatic deletion of anything unusual. Preserve raw input, require expected columns, validate keys/types/ranges and return rejected records with reasons for investigation.

This base R example accepts nonmissing unique IDs and numeric nonnegative amounts...

Related Questions