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 nuts_classify().

to_version

String with desired NUTS version the function should convert to. Possible versions: '2006', '2010', '2013', '2016' or '2021'

variables

Named character specifying variable names and variable type ('absolute' or 'relative') e.g. c('var_name' = 'absolute')

weight

String with name of the weight used for conversion. Can be area size 'areaKm' (default), population in 2011 'pop11' or 2018 'pop18', or artificial surfaces in 2012 'artif_surf12' and 2018 'artif_surf18'.

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 'error', when providing multiple NUTS versions within groups. If set to 'most_frequent' data is converted using the best-matching NUTS version.

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'))



[Package nuts version 1.0.0 Index]