Convert a vector of municipality names to municipality ids
Source: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
.
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?
Examples
if (kolada_available()) {
munic_df <- get_municipality()
munic_df %>%
municipality_name_to_id(c("Arboga", "Lund", "Stockholm", "Arboga"))
}
#> Arboga Lund Stockholm Arboga
#> "1984" "1281" "0180" "1984"