municipality_name_to_id {rKolada}R Documentation

Convert a vector of municipality names to municipality ids

Description

Given a vector of names of municipalities or regions, return a named vector of municipality IDs/codes. Codes of municipalities and regions follow the Swedish standard for municipality codes. The codes extracted can be used e.g. to pass as a parameter to get_values. This function is the inverse to municipality_id_to_name.

Usage

municipality_name_to_id(munic_df, municipality, remove_na = FALSE)

Arguments

munic_df

A Kolada Municipality metadata table, as created by e.g. get_municipality.

municipality

Name of one or several municipalities. Case insensitive. Allows repeats.

remove_na

Should NA return values be removed?

Value

A vector of Municipality IDs.

See Also

municipality_extract_ids, municipality_id_to_name

Examples

if (kolada_available()) {
munic_df <- get_municipality()
munic_df %>%
  municipality_name_to_id(c("Arboga", "Lund", "Stockholm", "Arboga"))
}


[Package rKolada version 0.2.3 Index]