Skip to contents

Calculates total aggregate final demand energy from a data frame of IEA data on both net and gross bases.

Usage

finaldemand_aggregates(
  .ieadata,
  country = IEATools::iea_cols$country,
  method = IEATools::iea_cols$method,
  energy_type = IEATools::iea_cols$energy_type,
  last_stage = IEATools::iea_cols$last_stage,
  year = IEATools::iea_cols$year,
  ledger_side = IEATools::iea_cols$ledger_side,
  flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
  flow = IEATools::iea_cols$flow,
  e_dot = IEATools::iea_cols$e_dot,
  consumption = IEATools::ledger_sides$consumption,
  eiou = IEATools::tfc_compare_flows$energy_industry_own_use,
  diff_colname = ".gross_less_net",
  net_aggregate_demand = IEATools::aggregate_cols$net_aggregate_demand,
  gross_aggregate_demand = IEATools::aggregate_cols$gross_aggregate_demand
)

Arguments

.ieadata

A data frame with columns of IEA data.

country, method, energy_type, last_stage, year, ledger_side, flow_aggregation_point, flow, e_dot

See IEATools::iea_cols.

consumption

See IEATools::ledger_sides.

eiou

See IEATools::tfc_compare_flows.

diff_colname

The name of a column containing differences between gross and net final demand. Default is ".gross_less_net".

net_aggregate_demand, gross_aggregate_demand

See IEATools::aggregate_cols.

Value

A data frame containing grouping columns of .ieadata and two additional columns containing net and gross final demand.

Details

This function works similar to dplyr::summarise(): it distills .ieadata to many fewer rows according to the grouping variables country, method, energy_type, last_stage, and year, and, possibly, additional grouping variables in the input (.ieadata).. .ieadata is grouped by those variables internally. Any grouping variables present in .ieadata are retained for calculating primary aggregate energy. Grouping is removed before output.

Examples

load_tidy_iea_df() %>% 
  finaldemand_aggregates()
#> # A tibble: 4 × 7
#>   Country Method Energy.type Last.stage  Year EX.fd_net EX.fd_gross
#>   <chr>   <chr>  <chr>       <chr>      <dbl>     <dbl>       <dbl>
#> 1 GHA     PCM    E           Final       1971   108221.     109143.
#> 2 GHA     PCM    E           Final       2000   225512.     226777.
#> 3 ZAF     PCM    E           Final       1971  1390363.    1429624.
#> 4 ZAF     PCM    E           Final       2000  2289581.    2437993.