Match Municipality Function
match_municipality.Rd
This function takes a data.table with municipality details and matches a provided municipality name to its corresponding municipality number for a given year, using Jaro-Winkler string matching method. An optional county number can be specified.
Arguments
- name
The name of the municipality.
- year
The year (optional). If not provided, the function will match the municipality irrespective of the year.
- county_number
The number of the county (optional).
- threshold
The minimum difference in string distance between the best and the second best match.
Value
The number of the municipality that matches the provided name and (if specified) year and county number, as well as the string distance and municipality name in a list.
Examples
if (FALSE) {
df <- data.table(
municipality_name = c("Municipality1", "Municipality2", "Municipality3"),
municipality_number = c(1001, 1002, 1003),
year_created = c(1900, 1920, 1940),
year_stopped = c(1950, 1980, 2020)
)
name <- "Municipality1"
year <- 1930
county_num <- 10
match_municipality(df, name, year, county_num)
}