Skip to contents

convert_table returns a list containing a data.table where values are converted from years into time periods and from one regional mapping to another. The function is calling convert_time_period and convert_region. More details about the parameters in these functions. The input table might be a data.table or a data.frame and should contain a column "value". All others columns are considered as indices.

Usage

convert_table(
  .x,
  ...,
  options = list(),
  time_mapping = NULL,
  from_reg = NULL,
  to_reg = NULL,
  agg_weight = NULL,
  regions = NULL,
  do_time_period = TRUE,
  do_region = TRUE,
  info = FALSE
)

Arguments

.x

a well-formatted data.table.

...

parameters to send to convert_region or convert_time_period.

options

a list of parameters to send to convert_region or convert_time_period.

time_mapping

a time mapping 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_weight

aggregation weight data.table

regions

optional list of region mappings (see Details for format)

do_time_period

logical indicating whether years should be converted.

do_region

logical indicating whether region should be converted.

info

logical indicating whether to include information, only necessary when the agg_operator is "sumby".

Value

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

See also

Examples

# Convert a country/year table into WITCH regions and time periods.
# Note that agg_weight and regions have no default here and must be given.
dt <- data.table::data.table(
  iso3 = rep(c("FRA", "DEU", "ITA"), 2),
  year = rep(c(2005, 2010), each = 3),
  value = as.numeric(1:6)
)

convert_table(dt,
              to_reg = "witch17",
              time_mapping = "t30",
              agg_weight = default_weights[["gdp"]],
              regions = region_mappings)
#>         t witch17 value
#>    <char>  <char> <num>
#> 1:      1  europe     6
#> 2:      2  europe    15