| esp_dict_region_code | R Documentation |
Convert Spanish subdivision names or identifiers among coding schemes such as NUTS, ISO2 and province codes. The function can also return human-readable names.
esp_dict_region_code(sourcevar, origin = "text", destination = "text")
esp_dict_translate(sourcevar, lang = "en", all = FALSE)
sourcevar |
Character string. Vector that contains the codes or names to be converted. |
origin, destination |
Character string. Coding scheme of origin and
destination. One of |
lang |
Character string. Target language code. Available values are
|
all |
Logical. If |
This function uses internal dictionaries together with countrycode
to map between schemes. When origin == destination == "text" the input is
returned unchanged. Mixing names from different administrative levels, for
example Autonomous Community or City and province, may produce NA values
for some entries.
esp_dict_region_code() returns a character vector with converted
subdivision identifiers or names. If a value cannot be matched, the
corresponding element will be NA and a warning is emitted via
cli::cli_warn().
esp_dict_translate() translates a vector of names from one language to
another. If all = FALSE, it returns a character vector with the translated
name for each element of sourcevar. If all = TRUE, it returns a named
list where each element contains all available translations for the
corresponding input value.
countrycode::countrycode() converts country codes and names.
esp_codelist documents the supported Spanish subdivision codes.
vals <- c("Errioxa", "Coruna", "Gerona", "Madrid")
esp_dict_region_code(vals)
esp_dict_region_code(vals, destination = "nuts")
esp_dict_region_code(vals, destination = "cpro")
esp_dict_region_code(vals, destination = "iso2")
# From ISO2 to other codes.
iso2vals <- c("ES-M", "ES-S", "ES-SG")
esp_dict_region_code(iso2vals, origin = "iso2")
esp_dict_region_code(iso2vals,
origin = "iso2",
destination = "nuts"
)
esp_dict_region_code(iso2vals,
origin = "iso2",
destination = "cpro"
)
# Mixing levels.
valsmix <- c("Centro", "Andalucia", "Seville", "Menorca")
esp_dict_region_code(valsmix, destination = "nuts")
esp_dict_region_code(valsmix, destination = "codauto")
esp_dict_region_code(valsmix, destination = "iso2")
vals <- c("La Rioja", "Sevilla", "Madrid", "Jaen", "Orense", "Baleares")
esp_dict_translate(vals)
esp_dict_translate(vals, lang = "es")
esp_dict_translate(vals, lang = "ca")
esp_dict_translate(vals, lang = "eu")
esp_dict_translate(vals, lang = "ga")
esp_dict_translate(vals, lang = "ga", all = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.