nuts_convert_version {nuts} | R Documentation |
Convert between NUTS versions
Description
nuts_convert_version()
transforms regional NUTS data between NUTS versions.
Usage
nuts_convert_version(
data,
to_version,
variables,
weight = NULL,
missing_rm = FALSE,
missing_weights_pct = FALSE,
multiple_versions = c("error", "most_frequent")
)
Arguments
data |
A nuts.classified object returned by |
to_version |
String with desired NUTS version the function should convert to. Possible versions: |
variables |
Named character specifying variable names and variable type ( |
weight |
String with name of the weight used for conversion. Can be area size |
missing_rm |
Boolean that is FALSE by default. TRUE removes regional flows that depart from missing NUTS codes. |
missing_weights_pct |
Boolean that is FALSE by default. TRUE computes the percentage of missing weights due to missing departing NUTS regions for each variable. |
multiple_versions |
By default equal to |
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 tibble containing NUTS codes, converted variable values, and possibly grouping variables.
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)
# Convert NUTS 2 codes in Germany from 2006 to 2021 version
manure %>%
filter(nchar(geo) == 4) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
filter(grepl('^DE', geo)) %>%
filter(time == 2003) %>%
select(-indic_ag, -time) %>%
# Data now only varies at the NUTS code level
nuts_classify(nuts_code = "geo") %>%
nuts_convert_version(to_version = '2021',
weight = 'pop18',
variables = c('values' = 'absolute'))
# Convert NUTS 3 codes by country x year, classifying version first
manure %>%
filter(nchar(geo) == 5) %>%
filter(indic_ag == 'I07A_EQ_Y') %>%
select(-indic_ag) %>%
# Data now varies at the year x NUTS code level
nuts_classify(nuts_code = 'geo', group_vars = c('time')) %>%
nuts_convert_version(to_version = '2021',
weight = 'pop18',
variables = c('values' = 'absolute'))