cassionData Analysis

Exercise · Beginner

Six changes and no log

You inherit a cleaning script with six undocumented steps and a coverage figure that has already been reported. Reconstruct the log, measure what each step cost, and identify the two steps that are wrong.

R45 min

The officer before you left this script and a penta3 coverage figure that is already in a quarterly report. There is no cleaning log. Nothing in the script errors, and the number it produces is plausible.

Your job is not to rewrite it. It is to say what it did, in a table someone could attach to the report.

The file

vaccination-coverage-2024.v1.csv — 2,736 rows of monthly aggregate reporting from 38 health facilities across six antigens. Synthetic, DHIS2-shaped, and carrying the defect that defines this kind of data: a facility that did not report and a facility that vaccinated nobody look identical.

The script

library(dplyr)
library(readr)

vax <- read_csv("vaccination-coverage-2024.v1.csv")

clean <- vax |>
  filter(doses_administered > 0) |>                          # 1
  filter(!is.na(target_population)) |>                       # 2
  mutate(antigen = tolower(antigen)) |>                      # 3
  distinct() |>                                              # 4
  filter(period >= as.Date("2024-03-01")) |>                 # 5
  mutate(coverage = doses_administered / target_population)

penta3 <- clean |>
  filter(antigen == "penta3") |>
  summarise(coverage = mean(coverage))                       # 6

The task

For each of the six numbered steps, produce one row of a cleaning log with these columns:

rule rows affected action effect on penta3 coverage is it defensible

Rules for filling it in:

  1. Rows affected is a number you computed, not an estimate. Show the code.
  2. Effect is measured, by running the pipeline with and without that step and subtracting. Everything else stays the same.
  3. “Is it defensible” is one of three answers — yes, yes with a caveat that must be reported, or no. If the answer is no, say what the step should have been instead.

Some steps affect zero rows. Those still get a log row; a rule that never fires is a fact about the data worth recording.

What to look for

Two of the six steps are wrong, in different ways. One destroys information the indicator depends on. One computes the wrong kind of average and is the more common mistake of the two in this sector.

Two useful reference points, both on penta3 and both monthly rather than annual: computed across every facility-month the file contains, coverage is about 5.1%; computed across only the facility-months where a report was actually submitted, it is about 6.5%. If neither of your figures resembles either of those, work out which step moved it before going further.

The questions to answer in prose

Three sentences each.

1. Step 1 drops every row where no doses were administered. Explain what those rows actually are in this dataset, what the resulting figure now measures, and which single column the script should have used instead.

2. Step 6 takes the mean of a column of ratios. Say what it computes, how it differs from total doses over total target population, and which of the two a district health officer means when they ask for coverage.

3. Step 5 keeps only March onward. It may be entirely correct. State the one thing you would need to know to decide, and say what belongs in the log if you cannot find out.

What to hand in

An R script producing the six-row log as a data frame, printed and written to outputs/reconstructed-log.csv, plus the corrected penta3 figure with its denominator stated in the column name.

How to know you are done

Your log’s effect column sums to the difference between the raw and final figures, or you can explain why it does not — some steps interact, and saying so is a better answer than a column that adds up by accident. Every row has a number in rows affected, including the zeros.