nuts_classify {nuts} | R Documentation |
Classify version of NUTS codes
Description
nuts_classify()
can identify the NUTS version year and level from a variable containing NUTS codes.
Usage
nuts_classify(
data,
nuts_code,
group_vars = NULL,
ties = c("most_recent", "oldest")
)
Arguments
data |
A data frame or tibble that contains a variable with NUTS |
nuts_code |
Variable name containing NUTS codes |
group_vars |
Variable name(s) for classification within groups. |
ties |
Picks |
Details
Console messages can be controlled with rlang::local_options(nuts.verbose = "quiet")
to silence messages and
nuts.verbose = "verbose"
to switch messages back on.
Value
A list of three tibbles. The first tibble contains the original data with the classified NUTS version, level, and country. The second tibble lists the group-specific overlap with each NUTS version. The third tibble shows missing NUTS codes for each group.
The output can be passed to nuts_convert_version()
to convert data across NUTS versions and nuts_aggregate()
to aggregate across NUTS levels.
Examples
library(dplyr)
# Load EUROSTAT data of manure storage deposits
data(manure)
# Data varies at the NUTS level x indicator x year x country x NUTS code level
head(manure)
# Classify version of NUTS 2 codes in Germany
manure %>%
filter(nchar(geo) == 4) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
filter(grepl('^DE', geo)) %>%
filter(time == 2003) %>%
select(-indic_ag, -time) %>%
# Data varies at the NUTS code level
nuts_classify(nuts_code = 'geo')
# Classify version of NUTS 3 codes within country and year
manure %>%
filter(nchar(geo) == 5) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
select(-indic_ag) %>%
# Data varies at the year x country x NUTS code level. The country grouping
# is always used by default.
nuts_classify(nuts_code = 'geo', group_vars = 'time')