Ir al contenido

Draws estimates by department or district on the INEI boundaries (fa_geometry()), ready for a paper: UTM zone 18S projection, a legend by classes, department names, a north arrow, a scale bar in kilometres and, around Peru, the Pacific Ocean, the neighbouring countries and a locator inset of South America. Areas without an estimate are grey; estimates that are only a reference (INEI "referencial": CV above 15% or few cases) get an asterisk and a dashed outline.

Uso

fa_map(
  x,
  value = "estimate",
  level = c("department", "district"),
  key = NULL,
  base = NULL,
  percent = TRUE,
  title = NULL,
  geometry = NULL,
  cache = fa_cache(),
  breaks = "quantile",
  n = 5,
  palette = "YlOrRd",
  labels = "name",
  context = TRUE,
  legend = NULL,
  quality = "quality"
)

Argumentos

x

A table with one row per area, e.g. from fa_estimate(), fa_indicator() or fa_link().

value

Column to map.

level

"department" or "district".

key

Column with the area code. By default department, ubigeo_base, ubigeo or domain, the first one found.

base

With level = "district", the census year of the codes in x (e.g. 2017 after fa_link()). The district boundaries are then merged into the districts of that year; districts that split from several of them stay grey.

percent

Show the values in percent.

title

Map title.

geometry

Boundaries to use instead of downloading them, an sf object with code and name as returned by fa_geometry().

cache

Cache folder for the boundaries.

breaks

How to group the values into classes: "quantile" (each class with about the same number of areas), "pretty" (round limits), a numeric vector of limits, or "continuous" for a colour gradient without classes.

n

Number of classes.

palette

A sequential palette from grDevices::hcl.colors(), such as "YlOrRd", "Teal", "Purples" or "Viridis", light for low values and dark for high ones.

labels

"name" (department names), "code" (INEI codes) or "none". Districts are never labelled.

context

Draw the ocean, the neighbouring countries, the locator inset, the north arrow and the scale bar.

legend

Legend title.

quality

Column with the INEI quality band (quality in fa_estimate()); NULL to ignore it.

Valor

A ggplot object.

Ejemplos

if (FALSE) { # \dontrun{
p <- fa_indicator("pobreza_monetaria", 2024, by = "department")
fa_map(p, title = "Monetary poverty 2024", legend = "Poor people")
fa_map(p, breaks = c(0, .1, .2, .3, .4, .5), palette = "Purples")
} # }