Skip to content

Instantly share code, notes, and snippets.

View Straubinger's full-sized avatar

Simon Grundt Straubinger Straubinger

View GitHub Profile
@Straubinger
Straubinger / municipalities_hierarchy
Last active November 13, 2021 17:16
Create parent-child hierarchy of Danish municipalities and regions
# This code creates a parent-child hierarchy of Danish municipalities and regions based on classifications from Statistics Denmark
dl_csv <- read.csv2("https://www.dst.dk/klassifikationsbilag/5d18d1e0-400b-4505-92ad-6782915980a3csv_da",
encoding = "UTF-8")
classifications <- dl_csv %>%
select(KODE, NIVEAU, TITEL) %>%
group_by(gr = cumsum(NIVEAU == 1)) %>%
mutate(region = TITEL[NIVEAU == 1L]) %>%
ungroup() %>%
@Straubinger
Straubinger / dk_cph_grid
Last active November 13, 2021 17:15
Grid of the districts of Copenhagen to be used with the 'geofacet' R package
# This code creates a grid of the districts of Copenhagen to be used with the 'geofacet' R package (https://hafen.github.io/geofacet/)
# Until the grid has been added to the package run the code to use the grid.
dk_cph_grid1 <- data.frame(
row = c(1, 1, 1, 1, 2, 2, 3, 3, 3, 3),
col = c(1, 2, 4, 3, 1, 3, 4, 3, 1, 2),
code = c("7", "8", "2", "3", "6", "1", "9", "10", "5", "4"),
name = c("Brønshøj-Husum", "Bispebjerg", "Østerbro", "Nørrebro", "Vanløse", "Indre By",
"Amager Øst", "Amager Vest", "Valby", "Vesterbro-Kgs. Enghave"),
stringsAsFactors = FALSE