Validate that geo_var
is conforming with the NUTS1
,
NUTS2
, or NUTS3
typologies.
While country codes are technically not part of the NUTS typologies,
Eurostat de facto uses a NUTS0
typology to identify countries.
This de facto typology has three exception which are handled by the
validate_nuts_countries function.
validate_nuts_regions(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.
Defaults to 2016
. 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
.
Returns the original dat
data frame with a column
that specifies the comformity with the NUTS definition of the year
nuts_year
.
NUTS typologies have different versions, therefore the conformity
is validated with one specific versions, which can be any of these:
1999
, 2003
, 2006
, 2010
,
2013
, the currently used 2016
and the already
announced and defined 2021
.
The NUTS typology was codified with the NUTS2003
, and the
pre-1999 NUTS typologies may confuse programmatic data processing,
given that some NUTS1 regions were identified with country codes
in smaller countries that had no NUTS1
divisions.
Currently the 2016
is used by Eurostat, but many datasets
still contain 2013
and sometimes earlier metadata.
Other validate functions:
validate_nuts_countries()
# \donttest{
my_reg_data <- data.frame (
geo = c("BE1", "HU102", "FR1",
"DED", "FR7", "TR", "DED2",
"EL", "XK", "GB"),
values = runif(10))
validate_nuts_regions (my_reg_data)
#> geo values typology valid_2016
#> 1 BE1 0.58859419 nuts_level_1 TRUE
#> 2 HU102 0.44658509 <NA> FALSE
#> 3 FR1 0.83457443 nuts_level_1 TRUE
#> 4 DED 0.31383924 nuts_level_1 TRUE
#> 5 FR7 0.88695284 iso-3166-alpha-3 FALSE
#> 6 TR 0.06938619 country TRUE
#> 7 DED2 0.59776393 nuts_level_2 TRUE
#> 8 EL 0.40761972 country TRUE
#> 9 XK 0.35687233 country TRUE
#> 10 GB 0.92262701 country TRUE
validate_nuts_regions (my_reg_data, nuts_year = 2013)
#> geo values typology valid_2013
#> 1 BE1 0.58859419 nuts_level_1 TRUE
#> 2 HU102 0.44658509 nuts_level_3 TRUE
#> 3 FR1 0.83457443 nuts_level_1 TRUE
#> 4 DED 0.31383924 nuts_level_1 TRUE
#> 5 FR7 0.88695284 nuts_level_1 TRUE
#> 6 TR 0.06938619 country TRUE
#> 7 DED2 0.59776393 nuts_level_2 TRUE
#> 8 EL 0.40761972 country TRUE
#> 9 XK 0.35687233 country TRUE
#> 10 GB 0.92262701 country TRUE
validate_nuts_regions (my_reg_data, nuts_year = 2003)
#> geo values typology valid_2003
#> 1 BE1 0.58859419 nuts_level_1 TRUE
#> 2 HU102 0.44658509 <NA> FALSE
#> 3 FR1 0.83457443 nuts_level_1 TRUE
#> 4 DED 0.31383924 nuts_level_1 TRUE
#> 5 FR7 0.88695284 nuts_level_1 TRUE
#> 6 TR 0.06938619 country TRUE
#> 7 DED2 0.59776393 nuts_level_2 TRUE
#> 8 EL 0.40761972 country TRUE
#> 9 XK 0.35687233 country TRUE
#> 10 GB 0.92262701 country TRUE
# }