mutation_count: Mutation count

View source: R/mutation_count.R

mutation_countR Documentation

Mutation count

Description

Count number of mutations in a given time period

Usage

mutation_count(
  mutations,
  start_date,
  end_date = Sys.Date(),
  territorial_changes_only = FALSE
)

Arguments

mutations

A tibble containing the municipality mutations inventory (see import_CH_municipality_inventory)

start_date

Date vector (incl)

end_date

Date vector (excluded)

territorial_changes_only

boolean. FALSE if all mutations should be considered. TRUE if mutations that have an effect on the municipal territory only should be considered. FALSE includes name changes, Bezirk number changes etc.

Details

Approach

  1. Download the Swiss municipality inventory

  2. Import it into R workspace with import_CH_municipality_inventory

  3. Set the old state and the new state (see example)

  4. 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:

  1. mapped: A tibble with the mapped municipalities

  2. unmapped: A tibble with the unmapped municipalities

  3. state_old: see above

  4. 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"))


SMMT documentation built on April 4, 2022, 1:07 a.m.