Skip to contents

Core data assembly

One call to a map-ready table, the light analysis table, and bare geometry.

world_data()
Map-ready, enriched country tibble
country_data()
Lightweight one-row-per-country table
world_geometry()
Geometry without the data
locate_country()
Tag coordinates with the country that contains them
country_borders()
Country adjacency (shared land borders)
neighbors()
A country's neighbours
distance_between()
Great-circle distance between two countries

Data sources beyond the World Bank

One verb, many providers. A registry rather than more Suggests, so a source with no CRAN package is still first class – and a way to find out where two providers disagree.

register_country_source()
Register a data source on the country spine
remove_country_source()
Remove a registered data source
country_sources()
The registered data sources
fetch_indicator()
Fetch an indicator from any registered source
add_indicator()
Fetch an indicator and join it to your data
compare_sources()
Do two sources agree?
fetch_owid() fetch_eurostat() fetch_oecd() fetch_comtrade()
Built-in source adapters
clear_country_cache()
Clear the cached downloads

Time

Historical borders, dated group membership, existence spans, and a check that a panel respects when countries actually existed.

historical_geometry()
Historical country boundaries
country_timeline()
A country's existence span, predecessors and successors
audit_time_coverage()
Does the data respect when countries existed?

The join engine

The package’s mission, exposed for your own data.

standardize_country()
Add ISO codes and classifications to any data frame
join_world()
One call: your data, on a map
attach_geometry()
Attach geometry to a country-level table
country_join()
Reconcile and join two messy country tables
country_join_all()
Join many messy country tables on the ISO spine
dissolve_country()
Resolve dissolved entities to their successor states

Diagnostics & data quality

Never lose a country silently.

check_country_match()
Pre-flight country-match report
repair_country_names()
Auto-repair country names to their closest known match
wdj_overrides() country_overrides()
Curated country-name overrides (replaces the silent drop-list)
audit_coverage()
Coverage / missingness audit

Reference data & code translation

convert_country()
Friendly country-code conversion
country_codes()
The countrycode codelist as a tidy tibble
country_groups()
Country-group membership
in_group()
Is a country in a group?
wdi_search()
Search World Bank indicators

Analysis helpers

per_capita()
Normalise an indicator by population
rate_check()
Flag rates computed over tiny denominators
smooth_rates()
Shrink unreliable rates toward the global rate
deflate()
Convert a money series to constant prices
to_ppp()
Convert to purchasing-power-parity terms
interpolate_missing()
Fill missing values, and say that you did
convergence_club()
Convergence clubs
aggregate_regions()
Roll countries up to region / income / continent
rank_countries()
Add rank, percentile and z-score
complete_years()
Fill or interpolate panel gaps
growth_rate()
Year-on-year (or compound) growth rate
index_to()
Rebase a series to an index (base year = 100)
share_of_world()
Each country's share of the world total
lag_by_country() diff_by_country()
Panel lag / difference by country
correlate_indicators()
Pairwise correlation of indicators on the spine
beta_convergence()
Beta convergence (growth regression)
sigma_convergence()
Sigma convergence (dispersion over time)
gini()
Gini coefficient (population-weightable)
theil()
Theil index, with between/within decomposition

Spatial statistics

Weights first, statistics second. country_weights() is the piece that lets an island participate at all – and lets adjacency be something other than geography.

country_weights()
Spatial weights on the country spine
morans_i()
Global Moran's I (spatial autocorrelation)
local_morans()
Local Moran's I (LISA)
lisa_map()
Map LISA clusters
gearys_c()
Geary's C (spatial autocorrelation)
getis_ord()
Getis-Ord G statistics (hot spots)
spatial_lag()
The neighbour average, as a column

Visualization

A full vocabulary of projected, area-honest maps.

world_map()
One-line choropleth, several honest styles
globe_map()
Orthographic globe choropleth
spin_globe()
Spin the globe
facet_map()
Small-multiple choropleths
bubble_map()
Proportional-symbol (bubble) map
spike_map()
Spike map (heights at country centroids)
bivariate_map()
Two-variable bivariate choropleth
cartogram_map()
Area-honest cartogram
dorling_map()
Dorling cartogram (first-class verb)
tile_map()
Equal-area world tile grid
flow_map()
Great-circle origin-destination flow map
animate_world()
Animate a choropleth over time
interactive_map()
Web-ready interactive choropleth
value_by_alpha_map()
Value-by-alpha: equalise a rate by its denominator
gridded_cartogram()
One square per N people
geom_country_labels()
Centroid-anchored country labels
theme_world_map()
A clean theme for world maps
simplify_geometry()
Simplify (thin) geometry for faster plotting

Honest maps

Say which classification you chose and what it did, show where the data is not, and make projection distortion visible rather than asserted.

classify_compare()
The same map under several classifications
coverage_map()
Map the data availability itself
projection_info()
What a projection preserves
projection_compare()
The same map under several projections
projection_distortion()
Measure what a projection distorts
tissot_map()
Tissot's indicatrix: what a projection does to the ground
cartogram_diagnostics()
Did the cartogram actually converge?
map_provenance()
What went into this map
dispute_policy()
State which map convention you are using
check_dispute_coverage()
Which disputed territories does your data touch?

Flows and networks

Bilateral data on the ISO spine.

flow_matrix()
An origin-destination table as a matrix
country_network()
Describe an origin-destination table as a network
od_map()
Origin-destination small multiples

Reporting

For the audience that wanted a table.

country_factsheet()
Everything the package knows about one country
world_table()
A publication-ready table from a map-ready frame

Subnational

Below the country level, scoped to where a maintained code system and free geometry both exist.

standardize_subnational()
Standardise subnational region names to ISO 3166-2
nuts_geometry()
NUTS geometry for Europe
subnational_map()
Map subnational data

Database rendering (ggsql)

Hand curated tables to ggsql for database-side spatial rendering.

as_ggsql_source()
Export a countryatlas table as a ggsql source
world_query()
Emit a ggsql spatial query for a country map

Performance & caching

clear_wdi_cache()
Clear the on-disk / in-memory WDI cache

Bundled datasets

world_snapshot
Offline snapshot of world data
country_meta
Static per-country metadata
common_indicators
Curated indicator catalogue
country_groups_tbl
Country-group membership (point-in-time)
world_tiles
Equal-area world tile-grid layout
historical_codes
Historical / dissolved entities and their successor states
country_groups_history
Dated country-group membership
disputed_territories
Disputed territories

Package

countryatlas countryatlas-package
countryatlas: join World Bank data, country codes and maps on the ISO spine