View source: R/changes_newcode.R
changes_newcode | R Documentation |
Wrapper for changes_group function, directly changing a vector of municipality codes to their correspoding new code following territorial changes.
changes_newcode(
old_codes,
y_start = 1857,
y_end = 2011,
muni_output = "largest",
partial_changes = FALSE,
checks = FALSE,
recycle = FALSE
)
old_codes |
Character vector, to be converted into new codes. |
y_start |
Integer, earliest year for which changes are considered. Default = 1857. |
y_end |
Integer, latest year for which changes are considered. Default = 2011. |
muni_output |
"largest" (default) or "first". If "largest", the municipality with highest population at y_end will be chosen as the output for the whole group. If "first", the municipality with the first code will be chosen. |
partial_changes |
(*In progress*) If TRUE, all municipalities that suffered partial changes will also be merged (Logical, default = FALSE). Partial changes refers to those cases where only a part of a municipality is affected, either because it gets transfered to another municipality or because a whole municipality splits and its territories become part of different municipalities. |
checks |
If TRUE, checks whether output includes all municipalities and no municipality is included in two groups (Logical, default = FALSE). *Note:* this option increases running time considerably. |
recycle |
If TRUE, saves municipality groups to global workspace to use when the function is run again. Useful to cut computing times when transforming several datasets for the same period (Logical, default = FALSE). *Note* recycle option saves an object called "muni_groups" to global workspace in R, and uses it in subsequent calls of the function. If dealing with different period transformation in the same R session, this option would lead to errors as no new municipality groups would be calculated. |
A character vector equivalent to the input.
# Bilbao, Zamudio & Derio & Zamudio Derio (Bizkaia)
changes_newcode(c("48020", "48513", "48534", "48535"), 1930, 1970)
changes_newcode(c("48020", "48513", "48534", "48535"), 1930, 1970, muni_output = "largest")
changes_newcode(c("48020", "48513", "48534", "48535"), 1930, 1970, checks = TRUE)
# Tapia de Casariego & Castropol (Asturias)
changes_newcode(c("33017", "33070"), 1860, 1900)
changes_newcode(c("33017", "33070"), 1887, 1900)
changes_newcode(c("33017", "33070"), 1860, 1900, muni_output = "largest")
changes_newcode(c("33017", "33070"), 1860, 2001, muni_output = "largest")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.