provinciator: Locate and homogenize Spanish territorial divisions

Description Usage Arguments Details Value Note See Also Examples

View source: R/provinciator.R

Description

Uses approximate string matching to infer the entity names in x and returns their official designation and geographical coordinates.

Usage

1
2
3
provinciator(x, division = "provincia", scope = bias())

provinciate(.data, .var, ...)

Arguments

x

A character vector.

division

The type of territorial division in x: "municipio" (includes "unidades poblacionales"), "provincia" or "ccaa".

scope

A list with class bias used to favor the string matching process of x towards or against selected regional divisions.

.data

A data frame.

.var

A variable from .data.

...

Other arguments passed to provinciator (except x).

Details

Geographical coordinates for "provincia" and "ccaa" refer to the capital of the chosen division type.

If scope is used, follow this example as a guide:

scope = bias("provincia", c(1, 20, 48:49), 4)

Basque provinces (1, 20 & 48) plus Zamora (49) will be prioritized when matching names in x and Almería (4) won't be used at all.

Value

For provinciator, a tibble (i.e. tbl_df) with the INE's official division names in x plus their geographical coordinates.

For provinciate, an object of the same class as .data with the results attached as new columns.

Note

By default, tibbles print no more than 3 decimals. Use options(pillar.sigfig = n) to change this number.

See Also

Use atlas to learn about the town names used by provinciator.

Examples

1
2
3
4
5
6
7
8
9
x. <- c("Almería", "Teruel", "Lérida")
provinciator(x.)


library(tidyverse)

edcn_towns <- edcn %>%
  provinciate(town_of_birth, "municipio") %>%
  select(town_of_birth, last_col(2:0), everything())

GuillermoNasarre/ihr documentation built on April 9, 2021, 9:44 a.m.