Skip to contents

Municipality mutation lists are required to compute matching tables for municipalities between different points in time.

Usage

swc_get_mutations(mids = NULL, canton = NULL)

Arguments

mids

A list of municipality id's (BFS-numbers) of which the mutations should be retrieved.

canton

Canton abbreviation as character (e.g. "GE", "ZH", "TI", etc.) to focus on. If left `NULL` (default) all cantons are considered.

Value

A data frame that represents mutations.

Details

The municipality dataset of the Swiss historicized communes data is a list of snapshots of municipality states. Each state is valid during a certain period of time, adjoining states are linked by admission and abolition numbers: The abolition number of a former state is the same as the admission number of a subsequent state. The states can be thought of as nodes in a graph, where the edges are mutations -- transformations from one state to the next.

This function performs a self-merge on the municipality data: Each abolition number is matched with its corresponding admission number (if available). If no corresponding admission or abolition number is found, the record is included with NAs instead of matched values. Records without admission or abolition number are excluded. The result is a list of mutations, i.e., a list of edges in the graph of municipality state snapshots.

Examples

head(swc_get_mutations(), 20)
#> # A tibble: 20 × 16
#>    mMutationNumber cAbbreviation mHistId.x mId.x mShortName.x mAbolitionMode
#>              <int> <chr>             <int> <int> <chr>        <chr>         
#>  1            1000 NA                   NA    NA NA           NA            
#>  2            1000 NA                   NA    NA NA           NA            
#>  3            1000 NA                   NA    NA NA           NA            
#>  4            1000 NA                   NA    NA NA           NA            
#>  5            1000 NA                   NA    NA NA           NA            
#>  6            1000 NA                   NA    NA NA           NA            
#>  7            1000 NA                   NA    NA NA           NA            
#>  8            1000 NA                   NA    NA NA           NA            
#>  9            1000 NA                   NA    NA NA           NA            
#> 10            1000 NA                   NA    NA NA           NA            
#> 11            1000 NA                   NA    NA NA           NA            
#> 12            1000 NA                   NA    NA NA           NA            
#> 13            1000 NA                   NA    NA NA           NA            
#> 14            1000 NA                   NA    NA NA           NA            
#> 15            1000 NA                   NA    NA NA           NA            
#> 16            1000 NA                   NA    NA NA           NA            
#> 17            1000 NA                   NA    NA NA           NA            
#> 18            1000 NA                   NA    NA NA           NA            
#> 19            1000 NA                   NA    NA NA           NA            
#> 20            1000 NA                   NA    NA NA           NA            
#> # ℹ 10 more variables: mAbolitionDate <date>, mDateOfChange.x <date>,
#> #   mHistId.y <int>, mId.y <int>, mShortName.y <chr>, mAdmissionMode <chr>,
#> #   mAdmissionDate <date>, mDateOfChange.y <date>, mMutationDate <date>,
#> #   mMutationId <ord>
head(subset(swc_get_mutations(), !is.na(mHistId.x)), 20)
#> # A tibble: 20 × 16
#>    mMutationNumber cAbbreviation mHistId.x mId.x mShortName.x     mAbolitionMode
#>              <int> <chr>             <int> <int> <chr>            <chr>         
#>  1            1001 VD                11248  5512 Bercher          Reassignment …
#>  2            1002 SO                11245  2451 Ichertswil       Abolition     
#>  3            1002 SO                11244  2455 Lüterkofen       Abolition     
#>  4            1003 VD                11242  5625 Bussy-sur-Morges Abolition     
#>  5            1003 VD                11243  5626 Chardonney-sur-… Abolition     
#>  6            1004 AG                11240  4021 Baden            Change of area
#>  7            1004 AG                11227  4025 Dättwil          Abolition     
#>  8            1005 VD                11238  5886 Montreux-Châtel… Abolition     
#>  9            1005 VD                11253  5887 Montreux-Planch… Abolition     
#> 10            1006 GR                11237  3972 Seewis im Präti… Change of nam…
#> 11            1007 GR                11236  3881 Conters im Prät… Change of nam…
#> 12            1008 FR                11235  2295 Grossbösingen    Change of nam…
#> 13            1009 GR                11234  3982 Disentis/Mustèr  Change of nam…
#> 14            1010 GR                11231  3597 Peiden           Abolition     
#> 15            1010 GR                11230  3602 Uors (Lumnezia)  Abolition     
#> 16            1011 SH                11233  2935 Herblingen       Abolition     
#> 17            1011 SH                11232  2939 Schaffhausen     Change of area
#> 18            1012 SG                11229  3404 Henau            Change of nam…
#> 19            1013 TG                11239  4756 Schönholzerswil… Change of area
#> 20            1013 TG                11266  4757 Toos             Abolition     
#> # ℹ 10 more variables: mAbolitionDate <date>, mDateOfChange.x <date>,
#> #   mHistId.y <int>, mId.y <int>, mShortName.y <chr>, mAdmissionMode <chr>,
#> #   mAdmissionDate <date>, mDateOfChange.y <date>, mMutationDate <date>,
#> #   mMutationId <ord>