Which records have a country to map?

In the December 1 TidyTuesday dataset on documented Catholic miracles, 1,799 of 1,990 records include a country. A map built from that column would include all 56 Lourdes Healing records and just five of the 91 Incorrupt Body records.

Horizontal bars show country-field completeness across six categories, from 5.5% to 100%. The table gives each count and denominator.

Reproduce the counts in Google Sheets

  1. Open a blank spreadsheet and choose Extensions → Apps Script.
  2. Paste the Apps Script source into the editor and save. You can also select it from the text below.
  3. Enter =TT_COUNTRY_COVERAGE() in cell A1. Leave A1:E7 empty beforehand so the results have room to expand.
Read and copy the Apps Script
// Returns one header and six category rows. Enter =TT_COUNTRY_COVERAGE()
// in an empty Google Sheet after saving this code in Extensions → Apps Script.
/**
 * Counts which December 1 TidyTuesday records have a country value.
 * Returns category, recorded, all rows, missing, and percent recorded (0–100).
 * @customfunction
 */
function TT_COUNTRY_COVERAGE() {
  const source = 'https://raw.githubusercontent.com/rfordatascience/tidytuesday/c608a60d1798bbcd73ac50bb573e470444a18c28/data/2026/2026-12-01/catholic_miracles.csv';
  const response = UrlFetchApp.fetch(source);
  const [header, ...records] = Utilities.parseCsv(response.getContentText('UTF-8'));
  const categoryColumn = header.indexOf('category');
  const countryColumn = header.indexOf('country');
  if (categoryColumn < 0 || countryColumn < 0) {
    throw new Error('The source must include category and country columns.');
  }

  const counts = new Map();
  for (const record of records) {
    if (record.length === 1 && !record[0].trim()) continue;
    if (record.length !== header.length || !record[categoryColumn].trim()) {
      throw new Error('A source row has missing columns or no category.');
    }
    const category = record[categoryColumn].trim();
    const country = record[countryColumn].trim();
    const count = counts.get(category) || { recorded: 0, total: 0 };
    count.total++;
    if (country && country !== 'NA') count.recorded++;
    counts.set(category, count);
  }

  const ranked = [...counts.entries()].sort(([nameA, a], [nameB, b]) =>
    b.recorded / b.total - a.recorded / a.total || nameA.localeCompare(nameB));
  const output = [['Category', 'Country recorded', 'All records', 'Missing', 'Percent recorded (0–100)']];
  for (const [name, count] of ranked) {
    output.push([name, count.recorded, count.total, count.total - count.recorded,
      Math.round(1000 * count.recorded / count.total) / 10]);
  }
  return output;
}

The function fetches the pinned public CSV. A blank country or the literal value NA counts as missing. Every record stays in its category’s denominator. Some descriptions contain line breaks, so the script parses the file as CSV before counting rows.

Country values in the weekly CSV
CategoryCountry recordedAll recordsShare
Lourdes Healing5656100.0%
Marian Apparition1,4031,47994.9%
Eucharistic Miracle13914794.6%
Miraculous Image15616793.4%
Stigmata405080.0%
Incorrupt Body5915.5%

Download the six category totals · Download the Python chart code. To rebuild the image, install Matplotlib and run python chart.py.

Source

Tony Galvan of Golden Dome Data Science curated Documented Catholic Miracles for the Data Science Learning Community’s TidyTuesday project, using records from MiracleHunter, the Carlo Acutis Eucharistic Miracles Exhibition and the Lourdes Sanctuary. A filled-in country records what the source file contains. Geographic accuracy, the frequency of events and the completeness of the original archives are separate questions.