Newer
Older
# download the lists of changes between the various NUTS versions from: https://ec.europa.eu/eurostat/en/web/nuts/history
# save the excel: D:\data\fadn\lieferung_20210414\yang\fadn_work_space\NUTS
# rm(list=setdiff(ls(), c("str_data","fadn.animal")))
rm (list = ls())
library(tidyverse)
library(data.table)
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# region rules #####
# https://ec.europa.eu/agriculture/rica/regioncodes_en.cfm?CodeCountry=EUR
region_transformation = TRUE
if (region_transformation) {
# deu ----
# 1981-2017
# version 2018
# 10, 20 merge into 15
de_region <- read.table(
text = "REGION REGION_new change_region
20 15 merge
10 15 merge", header = TRUE) %>%
as_tibble() %>% mutate (COUNTRY = "DEU")
# fra ----
# version 1981-2011
# vresion 2012
# new region 205,206,207
fra_region <- read.table(
text = "REGION REGION_new change_region
'' 205 'new region'
'' 206 'new region'
'' 207 'new region'", header = TRUE) %>%
as_tibble() %>% mutate(COUNTRY = "FRA")
# hun ----
# version 2004-2011
# version 2012-
# 761, 762, 763 merge into 768
# 760, 765, 766 merge into 767
hun_region <- read.table(
text = "REGION REGION_new change_region
761 768 merge
762 768 merge
763 768 merge
760 767 merge
765 767 merge
766 767 merge", header = TRUE) %>%
as_tibble() %>% mutate (COUNTRY = "HUN")
# por ----
# version 1986-2007
# version 2008
# 610,620 merge merge into 615
por_region <- read.table(
text = "REGION REGION_new change_region
610 615 merge
620 615 merge", header = TRUE) %>%
as_tibble() %>% mutate(COUNTRY = "POR")
region.trans <- do.call("rbind", list(de_region,fra_region,hun_region,por_region)) %>% mutate_if(is.integer, as.factor) %>%
mutate(change_region = as.character(change_region))
rm(de_region,fra_region,hun_region,por_region)
}
# str_data$info %>% left_join(region.trans, by = c("COUNTRY", "REGION")) %>%
# mutate(REGION_new = if_else(is.na(REGION_new),REGION, REGION_new),
# change_region = if_else(is.na(change_region),"no change", change_region))
# nuts1 rules ######
nuts1_transformation = TRUE
if (nuts1_transformation) {
# ell
ell_nuts1 <- read.table(
text = "NUTS1 NUTS1_new change_nuts1 version
GR1 EL1 'recoded' 2006To2010
GR2 EL2 'recoded' 2006To2010
GR3 EL3 recoded 2006To2010
GR4 EL4 recoded 2006To2010
EL1 EL5 'recoded, boundary shift' 2010To2013
EL2 EL6 'recoded, boundary shift' 2010To2013", header = TRUE) %>%
as_tibble() %>% mutate (COUNTRY = "ELL") %>%
mutate (regional_surface = case_when(NUTS1_new == "EL5" ~ 0.92,
NUTS1_new == "EL6" ~ 1.08,
TRUE ~1),
from_ex_NUTS2 = '',
from_NUTS2 = '',
convert = TRUE)
# fra -----
# FR1 1.00
# FRB 0.27
# FRC 0.55
# FRD 0.21
# FRE 1.13
# FRF 0.84
# FRG 0.38
# FRH 0.32
# FRI 0.87
# FRJ 0.84
# FRK 1.00
# FRL 0.46
# FRM 0.13
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
text = "NUTS1 NUTS1_new change_nuts1 from_ex_NUTS2 version regional_surface convert
FR9 FRA 'boundary shift' '' 2010To2013 1 TRUE
# FR2 '' discontinued '' 2013To2016
# FR3 '' discontinued '' 2013To2016
# FR4 '' discontinued '' 2013To2016
# FR5 '' discontinued '' 2013To2016
# FR6 '' discontinued '' 2013To2016
# FR8 '' discontinued '' 2013To2016
FRA FRY recoded '' 2013To2016 1 TRUE
FR7 FRK recoded '' 2013To2016 1 TRUE
FR2 FRB 'new region' 'FR24' 2013To2016 0.27 FALSE
FR2 FRC 'new region' 'FR26+FR43' 2013To2016 '' FALSE
FR4 FRC 'new region' 'FR26+FR43' 2013To2016 '' FALSE
FR2 FRD 'new region' 'FR23+FR25' 2013To2016 0.21 FALSE
FR2 FRE 'new region' 'FR22+FR30' 2013To2016 0.13 FALSE
FR3 FRE 'new region' 'FR22+FR30' 2013To2016 1 TRUE
FR2 FRF 'new region' 'FR21+FR41+FR42' 2013To2016 '' FALSE
FR4 FRF 'new region' 'FR21+FR41+FR42' 2013To2016 '' FALSE
FR5 FRG 'new region' FR51 2013To2016 0.38 FALSE
FR5 FRH 'new region' FR52 2013To2016 0.32 FALSE
FR5 FRI 'new region' 'FR53+FR61+FR63' 2013To2016 0.30 FALSE
FR6 FRI 'new region' 'FR53+FR61+FR63' 2013To2016 0.57 FALSE
FR6 FRJ 'new region' 'FR62+FR81' 2013To2016 0.43 FALSE
FR8 FRJ 'new region' 'FR62+FR81' 2013To2016 0.41 FALSE
FR8 FRL 'new region' FR82 2013To2016 0.46 FALSE
FR8 FRM 'new region' FR83 2013To2016 0.13 FALSE" , header = TRUE) %>%
# ita ----
ita_nuts1 <- read.table(
text = "NUTS1 NUTS1_new change_nuts1 version
ITD ITH 'boundary shift' 2006To2010
ITE ITI 'boundary shift' 2006To2010", header = TRUE) %>%
as_tibble() %>% mutate (COUNTRY = "ITA", from_ex_NUTS2 = '', from_NUTS2 = '', convert = TRUE) %>%
mutate (regional_surface = case_when(NUTS1_new == "ITH" ~ 1.01,
NUTS1_new == "ITI" ~ 0.99,
TRUE ~1) )
# pol ----
# PL7=PL11+PL33
# PL8=PL3-PL33
# PL9=PL12
pol_nuts1 <- read.table(
text = "NUTS1 NUTS1_new change_nuts1 from_ex_NUTS2 regional_surface version convert
# PL1 '' discontinued '' '' 2013To2016
# PL3 '' discontinued '' '' 2013To2016
PL1 PL7 'discontinued, new region' 'PL11+PL33' 0.34 2013To2016 FALSE
PL3 PL7 'discontinued, new region' 'PL11+PL33' 0.16 2013To2016 FALSE
PL3 PL8 'discontinued, new region' 'PL3-PL33' 0.84 2013To2016 FALSE
PL1 PL9 'discontinued, new region' PL12 0.66 2013To2016 FALSE
as_tibble() %>% mutate (COUNTRY = "POL", from_NUTS2 = '')
# sve ----
sve_nuts1 <- read.table(
text = "NUTS1 NUTS1_new change_nuts1 'from_ex_NUTS2' 'from_NUTS2' version
SE0 SE1 split 'SE01+SE02' 'SE11+SE12' 2003To2006
SE0 SE2 split 'SE09+SE04+SE0A' 'SE21+SE22+SE23' 2003To2006
SE0 SE3 split 'SE06+SE07+SE08' 'SE31+SE32+SE33' 2003To2006
as_tibble() %>% mutate (COUNTRY = "SVE",regional_surface = '', convert = FALSE)
nuts1.trans <- do.call("rbind", list(ell_nuts1,ita_nuts1,pol_nuts1,fra_nuts1, sve_nuts1)) %>%
mutate(change_nuts1 = as.character(change_nuts1))
rm(ell_nuts1,ita_nuts1,pol_nuts1, sve_nuts1)
}
#
# nuts2 rules ####
nuts2_transformation = TRUE
if (nuts2_transformation){
# deu ####
deu <- tibble(
NUTS2 = c("DEE1","DEE2","DEE3", "DE41", "DE42", "DED1", "DED3"),
NUTS2_new = c("DEE0","DEE0","DEE0", "DE40", "DE40", "DED4" ,"DED5"),
regional_surface = 1,
COUNTRY = "DEU",
version = c("2003To2006","2003To2006","2003To2006","2006To2010","2006To2010","2006To2010","2006To2010")
) %>% mutate(change = case_when(NUTS2_new == "DEE0" ~ "merge",
NUTS2_new == "DE40" ~ "merge",
NUTS2_new == "DED4" ~ "boundary shift, new region",
NUTS2_new == "DED5" ~ "boundary shift, new region",
Loading full blame...