NEWS


knbsdata 0.5.0

First release prepared for CRAN.

Breaking change: downloads name their destination

knbs_download_finaccess() and knbs_download_publication() no longer default destination to the working directory: the package writes only where you say. A call without one stops with a classed error that says so. The get calls knbs_search() and knbs_releases() hand back now name destination = "." explicitly.

Packaging

Health and demography from the KDHS

KNBS implements the Kenya Demographic and Health Surveys, and the DHS Program publishes their indicators through its Indicator Data API, now a source ("dhs_program"): 4,115 indicators from the KDHS of 1989 to 2022 and the 2015 and 2020 Malaria Indicator Surveys, through the same knbs_indicators() and knbs_get_indicator() as every other source.

Fixes found by a live run on 2026-10-15

Open survey microdata: FinAccess

The FinAccess household survey, Kenya's survey of financial inclusion by the Central Bank of Kenya, KNBS and FSD Kenya, publishes its anonymised, weighted microdata for anyone to download. The package now reaches it.

The portal states no licence. FSD Kenya's terms for the 2013 survey restrict it to research and forbid redistribution without written agreement, so assume nothing wider: the terms travel in each file's sidecar and metadata, the first download of a session names the producers, and no file is bundled with the package.

One provenance record per file

Provenance sidecars are now named after the whole file name: pop.dta gets pop.dta.metadata.json, where it used to get pop.metadata.json. The old name was shared by every file with the same stem, so knbs_write()-ing a table as pop.csv and pop.dta into one folder, or downloading a survey's Stata and SPSS copies side by side, left only the last file's record. Sidecars written by earlier versions keep their old names.

Quieter lookups

knbs_get_indicator() resolves an indicator against every source's catalogue, and warned "Could not reach: …" on every call while any one portal was down — even for an indicator served by another source. It now stays silent when the id is found in a source that answered. A name search still warns, since the unreachable catalogue might hold another match, and a not-found error names the unreachable source as a possible reason. The README leads its live examples with the most dependable sources and says what an outage looks like.

Twelve more Statistical Abstract chapters

knbs_abstract_table() now serves 48 tables of the 2025 Statistical Abstract, up from Chapter 2's fifteen: 33 more from Chapters 3–16 — wage employment by sector; the Post Office Savings Bank and insurance business; principal export commodities; crop sales and producer prices; forest plantations and wildlife; electricity connections and fuel sales; producer price indices and production of selected commodities; construction output by county and cement; visitor arrivals, departures and hotel occupancy; railway earnings, vehicle registration and inspection, Mombasa port and aircraft; school enrolment, by county too; and registered births and deaths by county. Each has a curated recipe, totals checked against their parts where the table has them, and pinned figures (audit F-39).

A survey of all 267 tables in the chapter workbooks found 38 in the layout the engine reads; the 33 curated are those, less four tables split across two sheets and Table 3.11.

What KNBS has released lately

New knbs_releases() lists what KNBS has put on its website, newest first: the last 30 days by default, any window with since and until, or one series' whole history with series = "cpi". Each row carries its release series, the period it covers and the call that downloads it.

Live: the last 30 days give the September 2026 CPI release and July's Leading Economic Indicators; the CPI series holds 255 distinct months.

Fixes

Files for Excel, Stata and SPSS, provenance included

New knbs_write() saves a result for colleagues who do not use R, and the provenance goes with it. The format follows the extension:

Codes stay text in every format ("01", never 1). Stata's 32-character limit shortens longer names, keeping their _code or _type ending and uniqueness, with the full name as the variable label and every rename recorded. List columns are written as JSON text and named in the provenance. A table derived with summarise() or a pivot is plain data: pass metadata = knbs_metadata(original) and its file carries the source's provenance; without it the file is written with a warning and says no provenance was attached. An existing file is never replaced unless overwrite = TRUE. writexl and haven join Suggests.

County names, matched across sources

County names are not spelled alike even inside KNBS: the census writes "Murang'a", "Tharaka-Nithi" and "Nairobi City", the Data Portal "MURANGA", "THARAKA NITHI" and "NAIROBI", each under its own codes. New knbs_county_code() turns county names — or numbers — written any way into the census frame's two-digit codes, ready for mutate() and a join; new knbs_match_counties() shows how each value matched.

One search across everything

New knbs_search() answers "where does this live?" in one call. It searches the indicator catalogues of every verified source, the survey archive, the publications library and the curated Abstract tables, and returns one ranked table — each row with get, the exact call that retrieves it: knbs_get_indicator("CPI_ALL_ITEMS", source = "knbs_cpi"), knbs_abstract_table("2.2"), knbs_survey_metadata(...), knbs_download_publication(...).

Rough edges: a silent row loss, readable columns, totals and parts

A live review on 2026-10-05 turned up places where correct data was still easy to misuse, or where it was not correct at all.

The cache moves to parser version 3 and schema version 2 (with the two source quirks below), so results cached in an older shape are re-fetched rather than served.

Two source quirks kept out of results

Both found by live testing on 2026-10-05.

The tidyverse contract, locked in tests

Every data-carrying result has always been a vctrs-backed tidy tibble; the behaviour is now guaranteed rather than incidental. Tests pin that dplyr verbs — filter(), mutate(), arrange(), select(), slice_max(), joins, bind_rows() — keep both the class and the provenance metadata (knbs_metadata() still answers on the result); that group_by() + summarise() and the tidyr pivots return plain tibbles, since a derived table is the caller's data rather than the source's; and that tibble::as_tibble() strips the wrapper cleanly. dplyr and tidyr join Suggests for these tests, and the getting-started and statistical-abstract vignettes now show the piped workflows, including pivot_wider() recreating the printed-table look.

The Statistical Abstract as tidy tables

The 2025 Statistical Abstract ships its chapter tables as Excel workbooks on the KNBS website (audit F-35). New knbs_abstract_tables() and knbs_abstract_table() turn the curated ones into clean tidy observations — starting with all fifteen tables of Chapter 2, National Accounts: the production accounts, GDP by activity at current and constant prices, expenditure on GDP, capital formation, national income and saving.

Gross County Product, via the Open Data for Africa republisher

The county economy arrives as data — from the one portal that serves it. knbs_indicators() and knbs_get_indicator() now also serve kenya.opendataforafrica.org (opendataforafrica in the registry), the Knoema-operated portal listed on KNBS's own portals page, which republishes 202 Kenyan datasets: 169 from KNBS under a "Public Domain" licence label, the rest from the Central Bank of Kenya, ministries and agencies (audit F-30). Chief among them: Gross County Product (knbs_get_indicator("jhbzkjc")) — GVA shares plus constant- and current-price GCP for all 47 counties, annual 2013–2020, which no first-party KNBS portal serves as data.

The KNBS Data Portal: 323 dataflows

The economy arrives as data. knbs_indicators() and knbs_get_indicator() now also serve the KNBS Data Portal (knbs_opendata in the registry) — an SDMX hub carrying 323 dataflows across five statistical domains: GDP by activity and by expenditure, GFCF, GNI, production accounts, CPI by division and by region, balance of payments, trade, money and banking, county government finance, employment, agriculture, tourism, health and justice (audit F-28).

knbsdata 0.4.0

Retail prices join the CPI family: what a kilogram of maize flour, a litre of petrol or a month's single-room rent actually costs, monthly back to 2019.

knbsdata 0.3.0

Consumer prices arrive as data, completing the plan's headline example: knbs_get_indicator("CPI_ALL_ITEMS", start = "2020-01").

Consumer prices

Other

knbsdata 0.2.0

Three new source families join the survey catalogue: publications, census tables as tidy indicators, and geographic reference codes. Every family is audited, adapter-built, tested offline against fixtures and verified live; vignette("source-status") states what each supports and what remains absent.

Geographic reference codes (Phase 6)

Census indicators (Phase 5)

The Phase 5 audit found a first-party machine-readable source: the KNBS census data service behind data.knbs.or.ke, built with Istat and serving 2019 Population and Housing Census tables as JSON-stat 2.0 under an explicit CC BY 4.0 statement.

Publications (Phase 4 completed)

The host that blocked Phase 4 recovered, its TLS chain fixed. The audit found the WordPress core REST API open over the site's media library — roughly 1,600 documents with direct, ungated file URLs — while the Download Monitor catalogue remains gated and untouched.

knbsdata 0.1.0

First release. It covers survey and census study discovery through the Kenya National Data Archive, and nothing else — see vignette("source-status") for what that excludes and why.

Survey catalogue

Provenance

Sources and health

Configuration and caching

Behaviour worth knowing

Known limitations

Internal