nuts_aggregate {nuts}R Documentation

Aggregate to higher order NUTS levels

Description

nuts_aggregate() transforms regional NUTS data between NUTS levels.

Usage

nuts_aggregate(
  data,
  to_level,
  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_level

Number corresponding to the desired NUTS level to be aggregated to: 1 or 2.

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, aggregated 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)

# Aggregate from NUTS 3 to 2 by indicator x year
manure %>%
  filter(nchar(geo) == 5) %>%
  nuts_classify(nuts_code = "geo",
                group_vars = c('indic_ag','time')) %>%
  # Group vars are automatically passed on
  nuts_aggregate(to_level = 2,
                 variables = c('values'= 'absolute'),
                 weight = 'pop18')


[Package nuts version 1.0.0 Index]