Validate your geo codes, pair them with the appropriate standard typology, look up potential causes of invalidity in the EU correspondence tables, and look up the appropriate geographical codes in the other (target) typology.
recode_nuts(dat, geo_var = "geo", nuts_year = 2016)A data frame with a 3-5 character geo_var variable
to be validated.
Defaults to "geo". The variable that contains
the 3-5 character geo codes to be validated.
The year of the NUTS typology to use.
You can select any valid
NUTS definition, i.e. 1999, 2003, 2006,
2010, 2013, the currently used 2016 and the
already announced and defined 2021. Defaults to the current
typology in force, which is 2016.
The original data frame with a 'geo_var' column is extended
with a 'typology' column that states in which typology is the 'geo_var'
a valid code. For invalid codes, looks up potential reasons of invalidity
and adds them to the 'typology_change' column, and at last it
adds a column of character vector containing the desired codes in the
target typology, for example, in the NUTS2013 typology.
A usual task is for example to validate geo codes in the 'NUTS2016'
typology and translate them to the now obsolete the 'NUTS2010' typology
to join current data with historical data sets.
Other recode functions:
get_country_code()
{
foo <- data.frame (
geo = c("FR", "DEE32", "UKI3" ,
"HU12", "DED",
"FRK"),
values = runif(6, 0, 100 ),
stringsAsFactors = FALSE )
recode_nuts(foo, nuts_year = 2013)
}
#> geo values typology typology_change
#> 1 FR 71.089636 country unchanged
#> 2 UKI3 48.549835 nuts_level_2 unchanged
#> 3 DED 78.997092 nuts_level_1 unchanged
#> 4 FRK 62.123632 nuts_level_1 Recoded from FRK [used in NUTS 2016-2021]
#> 5 HU12 68.894199 nuts_level_2 Used in NUTS 2016-2021
#> 6 DEE32 6.547995 nuts_level_3 Used in NUTS 1999-2003
#> code_2013
#> 1 FR
#> 2 UKI3
#> 3 DED
#> 4 FR7
#> 5 <NA>
#> 6 <NA>