Skip to contents

Report the provenance of a world_map() (or any plot the package's map verbs produced): the package version, the geometry backend and projection, the classification method and its breaks, the fill column, and how many countries are shown versus missing. These are the questions a reviewer asks first, and the answers are already known at plot time – this just makes them readable.

Usage

map_provenance(x, value = NULL)

Arguments

x

A plot returned by any of the package's map verbs – world_map() (either engine), bubble_map(), spike_map(), tile_map(), flow_map(), od_map(), globe_map(), bivariate_map(), cartogram_map(), dorling_map(), gridded_cartogram(), value_by_alpha_map(), coverage_map(), classify_compare(), facet_map(), lisa_map(), subnational_map() or projection_compare() – or a map-ready data frame, for which the data-side facts are reported and the drawing-side ones are NA.

tissot_map() is the one map verb that carries no provenance: it draws distortion ellipses for a projection and takes no data of yours.

value

For a data frame, the column whose coverage to report (unquoted). Ignored for a plot, which already knows its own fill.

Value

A one-row tibble of provenance fields, invisibly printed in a human-readable block. Fields: countryatlas, fill, backend, projection, style, n_bins, na_style, n_countries, n_missing, n_total, uncertainty, disputes, dispute_policy, n_imputed, breaks, missing_iso3c and snapshot_year.

The three counts are: n_countries, the countries actually drawn with a value; n_missing, those drawn without one; and n_total, the two added together – every country the map covers. n_countries is the numerator, not the denominator, which its name does not say on its own.

Putting it on the plot

world_map()(footnote = "auto") prints the coverage line as a caption, and classification_report = TRUE attaches the per-class counts. Together they cover what a methods note needs:

p <- world_map(mapdf, gdp_per_capita, style = "quantile",
               footnote = "auto", classification_report = TRUE)
map_provenance(p)
attr(p, "countryatlas_classification")

Examples

# \donttest{
snap <- countryatlas::world_snapshot$countries
if (requireNamespace("maps", quietly = TRUE)) {
  p <- attach_geometry(snap, geometry = "polygon") |>
    world_map(gdp_per_capita, style = "quantile")
  map_provenance(p)
}
#> 
#> ── countryatlas map provenance 
#> package: countryatlas 3.0.0 (snapshot 2024)
#> fill: gdp_per_capita
#> geometry: polygon backend, coord_quickmap
#> classification: quantile, 5 bins
#> missing data: grey
#> coverage: 189 countries shown, 51 missing
#> breaks: 268.7 | 1662 | 4594 | 10290 | 29370 | 247200
# }