Skip to contents

[Deprecated]

mn_join_by_name() was deprecated in mongolstats 0.3.0. Use mongolmaps::mn_join(), which joins by NSO code or by name in any spelling, drops national and regional totals, and takes Ulaanbaatar's figures from region code "5" when a table leaves code "511" empty.

Performs an exact join between a data frame and geoBoundaries polygons using normalized place names.

Usage

mn_join_by_name(data, name_col, level = "ADM1", boundaries = NULL)

Arguments

data

Data frame with a name column.

name_col

Column in data that contains names to join on.

level

Boundary level, passed to mn_boundaries() if boundaries not provided.

boundaries

Optional pre-fetched boundaries.

Value

An sf object with joined data. Data rows whose name matches no boundary are dropped with a warning (class mongolstats_unmatched_names) naming them.

Examples

if (FALSE) { # identical(Sys.getenv("NOT_CRAN"), "true") && curl::has_internet() && rlang::is_installed("sf")
pop_data <- data.frame(aimag = c("Ulaanbaatar", "Darkhan-Uul"), pop = c(1500000, 100000))
sf_joined <- mn_join_by_name(pop_data, "aimag", level = "ADM1")
# ->
if (rlang::is_installed("mongolmaps")) {
  sf_joined <- mongolmaps::mn_join(pop_data, by = "aimag", level = "aimag")
}
}