Sanity Checks

Before believing any result, check these.

Does the total match the source's total, and if not, why?

Does each group's size look plausible?

Are there values outside the possible range: negative counts, percentages above a hundred, dates in the future?

Does the number change if you re-run it? It should not.

If you compute it a second way, do you get the same answer?

Compute it twice, differently. The single most effective check in data work. Sum a column, then sum the group totals and compare. Count the rows, then count the distinct ids.

When the two disagree, you have found something real, and you have found it before publishing rather than afterwards.

◈ Graded Challenge

Write audit(rows) reporting what is questionable about a set of records, so it can be looked at before anything is published. Each row has an id, a value and a year. Return an object with four keys: total, the number of rows; duplicate_ids, how many rows carry an id already seen earlier; negative, how many rows have a value below zero; and future, how many rows have a year above 2026. Count each row independently for each check, so a single row can be counted in more than one.

Name it exactly: audit(rows)

3 visible + 6 hidden
loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Charts Make Claims →
← Back