aggregate_for_variable_by_list_nuts: Data aggregation function for a variable and a list of...

Description Usage Arguments Value Examples

View source: R/aggregate_for_variable_by_list_nuts.R

Description

Aggregates data for a variable and a list containing lists with nuts_ids to aggregate. Each object of the list is one region (aggregation unit) which has to contain NUTS IDs which will be aggregated. The name of the aggregated value is derived from the name of the list object, the variable name and the level of the NUTS_units.

Usage

1
2
3
4
5
6
7
aggregate_for_variable_by_list_nuts(
  VarName,
  nuts_list,
  group_by = "sum",
  data = EntrancesData,
  NUTS_level = "NUTS3"
)

Arguments

VarName

character string with the name of the variable.

nuts_list

list, were each object contains nuts_ids. The data will be aggregated for the NUTS IDs in each object of the list and the object name of the list will be used for the regional ID of the aggregated observation.

group_by

"sum", "mean", "median", indicates whether aggregation should work by using the sum, the mean or the median of the data.

data

dataframe, from which you want to extract your data. Default is the EntrancesData dataset

NUTS_level

indicates, which regional level should be used for aggregation. Default is "NUTS3".

Value

dataframe

Examples

1
2
3
4
5
6
7
8
#First generate a List with region objects containing NUTS IDs. The object name (e.g. Germany) will be used as variable Name for the aggregated variable.
#Then you can use the list to aggregate the values of a variable for the NUTS IDs in each list object.
#Aggregation can work either by sum, mean or median.
#Additionally you can filter your NUTS IDs for a specific level (NUTS3, NUTS2, NUTS1, NUTS country).
#You can define a data frame, if you don't want to use the EntrancesData data set from the package.

list_with_NUTS<-list(Germany=c("DED01", "DED02"), Italy=c("ITG2c", "ITG2B"))
aggregate_for_variable_by_list_nuts(VarName="pop", nuts_list=list_with_NUTS, group_by="sum", data=EntrancesData, NUTS_level="NUTS3")

THartl1/EntrancesDataPackage documentation built on Dec. 18, 2021, 4:01 p.m.