R/municipality.R
municipality_name_to_id.Rd
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
.
municipality_name_to_id(munic_df, municipality, remove_na = FALSE)
A Kolada Municipality metadata table, as created by e.g.
get_municipality
.
Name of one or several municipalities. Case insensitive. Allows repeats.
Should NA return values be removed?
A vector of Municipality IDs.
munic_df <- get_municipality()
munic_df %>%
municipality_name_to_id(c("Arboga", "Lund", "Stockholm", "Arboga"))
#> Arboga Lund Stockholm Arboga
#> "1984" "1281" "0180" "1984"