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 |
to_level |
Number corresponding to the desired NUTS level to be aggregated to: |
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, 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')