UnicefData
unicefData is an open data and analytics platform led by UNICEF’s Office of the Chief Statistician, providing reproducible, standards-based tools for accessing and using official child-related statistics.
Install / Use
/learn @unicef-drp/UnicefDataREADME
unicefData
Trilingual R, Python, and Stata library for downloading UNICEF child welfare indicators via SDMX API
The unicefData package provides lightweight, consistent interfaces to the UNICEF SDMX Data Warehouse in R, Python, and Stata. Fetch any indicator series by specifying its SDMX key, date range, and optional filters.
Repository Structure
unicefData-dev/
├── r/ # R package (CRAN) - branch here for devtools::release()
│ ├── R/ # 16 source files
│ ├── tests/ # R package tests
│ ├── NEWS.md # R-specific changelog
│ ├── DESCRIPTION # Package metadata
│ └── ...other R package files
├── python/ # Python package (PyPI)
│ ├── CHANGELOG.md # Python-specific changelog
│ └── ...Python package files
├── stata/ # Stata package (SSC)
│ ├── CHANGELOG.md # Stata-specific changelog
│ └── ...Stata package files
├── paper/ # Academic documentation (LaTeX)
├── tests/ # Cross-language validation tests
├── metadata/ # Shared YAML/CSV metadata
├── docs/ # Technical documentation
├── README.md # This file (repository overview)
├── CHANGELOG.md # Multi-language changelog (overview)
└── CONTRIBUTING.md # Developer guidelines
Platform Documentation
| Platform | README | Changelog | Version | |----------|--------|-----------|---------| | R | r/README.md | r/NEWS.md | 2.4.0 (CRAN) | | Python | python/README.md | python/CHANGELOG.md | 2.4.1 (PyPI) | | Stata | stata/README.md | stata/CHANGELOG.md | 2.4.0 (SSC) |
Repository Documentation
| Document | Purpose | |----------|---------| | CHANGELOG.md | Multi-language changelog overview | | CONTRIBUTING.md | How to contribute (all languages) | | docs/ | Technical documentation index |
Quick Start
All three platforms use the same functions with nearly identical parameters.
Python
from unicefdata import unicefData, search_indicators, list_categories
# Search for indicators
search_indicators("mortality")
list_categories()
# Fetch data (dataflow auto-detected)
df = unicefData(
indicator="CME_MRY0T4",
countries=["ALB", "USA", "BRA"],
year="2015:2023"
)
R
library(unicefData)
# Search for indicators
search_indicators("mortality")
list_categories()
# Fetch data (dataflow auto-detected)
df <- unicefData(
indicator = "CME_MRY0T4",
countries = c("ALB", "USA", "BRA"),
year = "2015:2023"
)
Stata
* Search for indicators
unicefdata, search(mortality)
unicefdata, flows
* Fetch data (dataflow auto-detected)
unicefdata, indicator(CME_MRY0T4) countries(ALB USA BRA) year(2015:2023) clear
Installation
R
devtools::install_github("unicef-drp/unicefData")
library(unicefData)
Python
git clone https://github.com/unicef-drp/unicefData.git
cd unicefData/python
pip install -e .
Stata
* Using github package (recommended)
net install github, from("https://haghish.github.io/github/")
github install unicef-drp/unicefData, package(stata)
See platform-specific READMEs for detailed installation options.
Features
| Feature | R | Python | Stata |
|---------|:-:|:------:|:-----:|
| Unified API | unicefData() | unicefData() | unicefdata |
| Search indicators | search_indicators() | search_indicators() | unicefdata, search() |
| List categories | list_categories() | list_categories() | unicefdata, categories |
| Auto dataflow detection | ✅ | ✅ | ✅ |
| Filter by country, year, sex | ✅ | ✅ | ✅ |
| Wide/long formats | ✅ | ✅ | ✅ |
| Latest value per country | ✅ | ✅ | ✅ |
| MRV (most recent values) | ✅ | ✅ | ✅ |
| Circa (nearest year) | ✅ | ✅ | ✅ |
| Add metadata (region, income) | ✅ | ✅ | 🔜 |
| 700+ indicators | ✅ | ✅ | ✅ |
| Automatic retries | ✅ | ✅ | ✅ |
| Cache management | clear_unicef_cache() | clear_cache() | unicefdata, clearcache |
| Timeout exceptions | ✅ | SDMXTimeoutError | ✅ |
Core Parameters
| Parameter | Type | Description |
|-----------|------|-------------|
| indicator | string/vector | Indicator code(s), e.g., "CME_MRY0T4" |
| countries | vector | ISO3 codes, e.g., ["ALB", "USA"] |
| year | int/string | Single (2020), range ("2015:2023"), or list |
| sex | string | "_T" (total), "F", "M", or "ALL" |
| format | string | "long", "wide", or "wide_indicators" |
| latest | boolean | Keep only most recent value per country |
| mrv | integer | Keep N most recent values per country |
| circa | boolean | Find closest available year |
See platform READMEs for complete parameter documentation.
Available Categories
| Category | Count | Description | |----------|------:|-------------| | NUTRITION | 112 | Stunting, wasting, etc. | | CAUSE_OF_DEATH | 83 | Causes of death | | CHILD_RELATED_SDG | 77 | SDG targets | | WASH_HOUSEHOLDS | 57 | Water & Sanitation | | PT | 43 | Child Protection | | CHLD_PVTY | 43 | Child Poverty | | CME | 39 | Child Mortality | | EDUCATION | 38 | Education | | HIV_AIDS | 38 | HIV/AIDS | | MNCH | 38 | Maternal & Child Health | | IMMUNISATION | 18 | Immunization |
Use list_categories() for the complete list (733 indicators across 22 categories).
Common Indicators
| Indicator | Dataflow | Description |
|-----------|----------|-------------|
| CME_MRY0T4 | CME | Under-5 mortality rate |
| CME_MRM0 | CME | Neonatal mortality rate |
| NT_ANT_HAZ_NE2_MOD | NUTRITION | Stunting prevalence |
| IM_DTP3 | IMMUNISATION | DTP3 coverage |
| IM_MCV1 | IMMUNISATION | Measles coverage |
| WS_PPL_W-SM | WASH | Safely managed water |
| PT_CHLD_Y0T4_REG | PT | Birth registration |
Project Structure
unicefData/
├── R/ # R package source
├── python/ # Python package source
├── stata/ # Stata package source
│ └── qa/ # Stata QA test suite (63 tests)
├── tests/
│ ├── fixtures.zip # Authoritative test fixtures (single source)
│ ├── fixtures/ # Unpacked fixtures (auto-extracted)
│ └── testthat/ # R unit tests (105 tests)
├── scripts/
│ ├── generate_fixtures.py # Download + pack fixtures from API
│ └── unpack_fixtures.py # Extract ZIP to all platform dirs
├── .githooks/ # Auto-unpack on clone/pull
├── validation/ # Cross-platform validation
├── internal/docs/ # Dev-only documentation
│ ├── TEST_REFERENCE.md # Full cross-platform test map
│ ├── QA_SETUP.md # Environment setup guide
│ └── FIXTURE_INFRASTRUCTURE.md # ZIP fixture system
├── DESCRIPTION # R package metadata
├── NEWS.md # Changelog
└── README.md # This file
CRAN Submission (R)
The R package is in the r/ directory and ready for CRAN submission:
# Navigate to R package
setwd("C:/GitHub/myados/unicefData-dev/r")
# Final validation
devtools::check(args = "--as-cran")
# Expected: 0 errors | 0 warnings | 2 notes (acceptable for new submission)
# Test on R-hub builders (Windows/macOS/Linux)
devtools::check_win_devel()
devtools::check_win_release()
# Build package
devtools::build()
# Submit to CRAN (interactive)
devtools::release()
See r/cran-comments.md for current submission status and reviewer responses.
Project Structure Old
unicefData/
├── R/ # R package source
├── python/ # Python package source
├── stata/ # Stata package source
│ └── qa/ # Stata QA test suite (63 tests)
├── tests/
│ ├── fixtures.zip # Authoritative test fixtures (single source)
│ ├── fixtures/ # Unpacked fixtures (auto-extracted)
│ └── testthat/ # R unit tests (105 tests)
├── scripts/
│ ├── generate_fixtures.py # Download + pack fixtures from API
│ └── unpack_fixtures.py # Extract ZIP to all platform dirs
├── .githooks/ # Auto-unpack on clone/pull
├── validation/ # Cross-platform validation
├── internal/docs/ # Dev-only documentation
│ ├── TEST_REFERENCE.md # Full cross-platform test map
│ ├── QA_SETUP.md # Environment setup guide
│ └── FIXTURE_INFRASTRUCTURE.md # ZIP fixture system
├── DESCRIPTION # R package metadata
├── NEWS.md # Changelog
└── README.md # This file
v2.3.0 (2026-02-18) — Stata only
- Frame-based discovery caching: indicator search parsed once per session, subsequent
search()calls near-instantaneous (Stata 16+) - New
nocacheoption and automatic cache invalidation onunicefdata_sync - Archived vestigial wbopendata helper programs
- Bug fixes from v2.2.1 code review (4 high-priority fixes, 7 cleanup items)
v2.2.0 (2026-02-15)
**Cross-Platform Testing Infrast
