name_to_code | R Documentation |
Returns INE codes corresponding to municipality names.
name_to_code(muni, prov = NULL, year = NULL, year_excl = NULL, force = FALSE)
muni |
Character string or character vector. It returns a character vector of INE codes equivalent to the input. If not found, it returns NA. In case two codes share a municipality name in the same province, it returns the municipality existing in latest census, or the one that had the name in latest census. Otherwise, it gives a warning. Usually, these problems are due to a municipality changing name and code, and then returning to the old denomination, but there might be more problematic cases. |
prov |
Optional, character vector. Include in case of name duplicates. If a duplicate is found and no province was specified, it returns an error message. If only one value is given for a set of municipalities, it is expanded to all of them. Accepts official names, case-insensitive: Alava, Albacete, Alicante, Almeria, Avila, Badajoz, Baleares, Barcelona, Burgos, Caceres, Cadiz, Castellon, Ceuta, Ciudad Real, Cordoba, A Coruna, Cuenca, Girona, Granada, Guadalajara, Gipuzkoa, Huelva, Huesca, Jaen, Leon, Lleida, La Rioja, Lugo, Madrid, Malaga, Melilla, Murcia, Navarra, Ourense, Asturias, Palencia, Las Palmas, Pontevedra, Salamanca, Santa Cruz de Tenerife, Cantabria, Segovia, Sevilla, Soria, Tarragona, Teruel, Toledo, Valencia, Valladolid, Bizkaia, Zamora, Zaragoza. Also: Araba, La Coruna, Gerona, Lerida, Guipuzcoa, Vizcaya. |
year |
Integer, code_list will be restricted to municipalities existing in a particular census year. Must be a valid census year. |
year_excl |
Integer, code_list will exclude a particular census year. Must be a valid census year. |
force |
Logical (default = FALSE), if TRUE, it will return codes even if some municipaly names were found duplicated in more than one provinces (these will be returned as NA). |
Character vector equivalent to the input. NA if not found.
# name_to_code("Tapia") # Returns an error
# name_to_code(c("Tapia", "Castropol")) # Returns an error
name_to_code(c("Tapia", "Castropol"), force = TRUE)
name_to_code("Tapia de Casariego")
name_to_code(c("Tapia", "Castropol"), rep("Asturias", 2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.