Skip to contents

convert_region returns a list containing a data.table where values are converted from one regional mapping to another. The conversion is done by downscaling values at country-level (if necessary) and updscaling them into the final regional mapping. The list also contain an optional data.table about the value coperture for the operator sumby. The required format of the input data is described in Details.

Usage

convert_region(
  .x,
  from_reg = NULL,
  to_reg,
  agg_operator = "sum",
  agg_weight = witchtools::default_weights[["gdp"]],
  agg_missing = "NA",
  regions = witchtools::region_mappings,
  info = FALSE
)

Arguments

.x

a well-formatted data.table.

from_reg

initial regional mapping name or a data.table with the mapping.

to_reg

final regional mapping name or a data.table with the mapping.

agg_operator

aggregation operator (See Details for the list of possible values)

agg_weight

aggregation weight data.table (See Details for the list of possible values)

agg_missing

tells how to deal with missing values ("NA" or "zero")

regions

optional list of region mappings (see Details for format)

info

logical indicating whether to include information, only required for the agg_operator "sumby".

Value

a list containing a converted data.table and information about the coperture if available.

Details

The input data.table should contain a column "value" and a column named by the initial regional mapping from_reg, while the other columns are are considered as id columns. The resulting data.table have a column named by the final regional mapping to_reg.

The regional mapping for from_reg and to_reg can be provided in a named list through the parameter regions. Regional mappings are 2-columns data.table with a column named 'iso3' (for country ISO3) and another one named as the regional mapping (for region name). The name in the list should also be the regional mapping name.

See also

Examples

if (FALSE) {

convert_region(gdp_iso3, to_reg = "witch17")
}