map_old_to_new_state {SMMT} | R Documentation |
Map municipalities of old state to municipalities of new state
Description
This function maps the Swiss municipalities of an old state to municipalities of a new state.
Usage
map_old_to_new_state(mutations, state_old, state_new)
Arguments
mutations |
A tibble containing the municipality mutations inventory (see
|
state_old |
A Date object vector of length one containing the date of the old state. |
state_new |
A Date object vector of length one containing the date of the new state. |
Details
Approach
Download the Swiss municipality inventory
Import it into R workspace with
import_CH_municipality_inventory
Set the old state and the new state (see example)
Get the mapping table with this function
Example Daettwil / Baden
On 1.1.1962 Daettwil (Bfs Nr. 4025) merged with Baden (Bfs Nr. 4021). Let's define
old_state <- as.Date("1961-01-01")
-
new_state <- as.Date("1963-01-01")
Result:
bfs_nr_new name_new bfs_nr_old name_old 4021 Baden 4021 Baden 4021 Baden 4025 Daettwil
Value
A list with 4 elements:
mapped: A tibble with the mapped municipalities
unmapped: A tibble with the unmapped municipalities
state_old: see above
state_new: see above
Examples
mutations <- structure(list(hist_id = c(11227L, 11240L, 13189L),
district_hist_id = c(10025L, 10025L, 10025L),
kanton_abbr = c("AG", "AG", "AG"),
bfs_nr = c(4025L, 4021L, 4021L),
name = c("Daettwil", "Baden", "Baden"),
admission_nr = c(1000L, 1000L, 1004L),
admission_mode = c(20L, 20L, 26L),
admission_date = structure(c(-3653, -3653, -2922),
class = c("Date")),
abolition_nr = c(1004L, 1004L, NA),
abolition_mode = c(29L, 26L, NA),
abolition_date = structure(c(-2923, -2923, NA),
class = c("Date")),
change_date = structure(c(-2923, -2923, -2922), class = c("Date"))),
row.names = c(NA, -3L), class = c("tbl_df", "tbl", "data.frame"))
mapping_object <- map_old_to_new_state(mutations,
as.Date("1961-01-01"), as.Date("1963-01-01"))