Skip to content

Extract hardcoded data patches into a private patch file + generic apply_patches() #30

Description

@WestonVoglesonger

Problem

Manual, per-school data corrections are currently hardcoded directly into cleaning code rather than supplied as data. This makes the cleaning logic state-specific, hard to review, and forces correction data into version control (a problem since these repos are intended to go public).

Locations:

  • inst/templates/03_state_cleaning.R:240-267hardcode_school_addresses() with one fix(...) call per school (address, city, zip, lat/lon, business status).
  • The same anti-pattern leaks into the package itself: state-specific corrections embedded in R/preprocessing_utils.R — e.g. the "oosle" MD nonpublic-school pattern (:334) and the redaction strings (:244, :252).

Suggested direction

Two clean inputs -> one generic applier:

  1. Raw data file (already handled).
  2. Patch file — a state-specific table of corrections (e.g. match_key, field, new_value, or a wide form mirroring the current fix() signature). Kept private / gitignored, the same way raw data is.
  3. A package function apply_patches(data, patch_file) that applies the corrections programmatically. No school names or manual fixes in .R files.

Open design questions:

  • Match key: the current approach matches on school_name_orig, which is brittle and order-dependent. Decide on a stable key (school id?) before formalizing.
  • Decide patch file format (CSV vs YAML) and where the template references it.

Context

Raised by Carl: be careful about hardcoding patch entries in cleaning; keep the patch file private; don't commit patches or raw data (repos will be public in future).

Scope

Design + abstraction only — do not implement until confirmed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions