disaggregate_dt: Disaggregate data in a data.table object using a mapping. If...

View source: R/aggregate.R

disaggregate_dtR Documentation

Disaggregate data in a data.table object using a mapping. If no weights are given, the value for the aggregated categories is used on the disaggregated ones. If a weight is given, the values from the aggregated categories are distributed according to the weights.

Description

Disaggregate data in a data.table object using a mapping. If no weights are given, the value for the aggregated categories is used on the disaggregated ones. If a weight is given, the values from the aggregated categories are distributed according to the weights.

Usage

disaggregate_dt(
  data,
  mapping,
  fewcol = "region",
  manycol = "iso",
  valuecol = "value",
  datacols = "data",
  weights = NULL,
  weightcol = "weight"
)

Arguments

data

a data.table.

mapping

a mapping between the aggregated categories and their parts. *All* aggregated categories in 'data' have to be part of the mapping.

fewcol

name of the column containing aggregated categories. Default is "region".

manycol

name of the column containing dis-aggregated categories. Default is "iso".

valuecol

name of the column with the actual value to disaggregate, default is 'value'.

datacols

index columns that label categories which have to be treated seperately when dis-aggregating with a weight.

weights

table with weights for disaggregation, the name of the column with the aggregated categories has to be 'manycol'. If columns (other than the column with the aggregated category) of the 'weights' coincide with columns of the data, the respective columns are considered when joining.

weightcol

column with the weights for the dis-aggregation, default is 'weight'.


pik-piam/rmndt documentation built on April 21, 2024, 4:31 a.m.