This function is mainly a wrapper around the well-known countrycode function, with three exception that are particular to the European Union statistical nomenclature.

validate_nuts_countries(dat, geo_var = "geo")

Arguments

dat

A data frame with a 2-character geo variable to be validated

geo_var

Defaults to "geo". The variable that contains the 2 character geo codes to be validated.

Value

The original data frame extended with the column 'typology'. This column states 'country' for valid country typology coding, or appropriate label for invalid ISO-3166-alpha-2 and ISO-3166-alpha-3 codes.

Details

All ISO-3166-1 country codes are validated, and also the three exceptions.

EL

Treated valid, because NUTS uses EL instead of GR for Greece since 2010.

UK

Treated valid, because NUTS uses UK instead of GB for the United Kingdom.

XK

XK is used for Kosovo, because Eurostat uses this code, too.

See also

Other validate functions: validate_nuts_regions()

Examples

{
my_dat <- data.frame (
 geo = c("AL", "GR", "XK", "EL", "UK", "GB", "NLD", "ZZ" ),
 values = runif(8)
 )

 ## NLD is an ISO 3-character code and is not validated.
 validate_nuts_countries(my_dat)
}
#>   geo    values                 typology
#> 1  AL 0.2898165                  country
#> 2  GR 0.8117068                  country
#> 3  XK 0.5501248                  country
#> 4  EL 0.6236655                  country
#> 5  UK 0.2250025                  country
#> 6  GB 0.6743132                  country
#> 7 NLD 0.6760750         iso-3166-alpha-3
#> 8  ZZ 0.7387578 invalid_iso-3166-alpha-2