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

finaldemand_aggregates_IEA(
  .ieadata,
  ledger_side = "Ledger.side",
  flow_aggregation_point = "Flow.aggregation.point",
  flow = "Flow",
  energy = "E.dot",
  consumption = "Consumption",
  eiou = "Energy industry own use",
  aggregate_net_finaldemand = Recca::aggregate_cols$aggregate_net_finaldemand_iea,
  aggregate_gross_finaldemand = Recca::aggregate_cols$aggregate_gross_finaldemand_iea
)

Arguments

.ieadata

a data frame with columns of IEA data.

ledger_side

the name of the ledger side column in .ieadata. Default is "Ledger.side".

flow_aggregation_point

the name of the flow aggregation point column in .ieadata. Default is "Flow.aggregation.point".

flow

the name of the column that contains flow information. Default is "Flow".

energy

the name of the column that contains energy information. Default is "E.dot".

consumption

the identifier for consumption in the flow_aggregation_point column. Default is "Consumption".

eiou

the identifier for energy industry own use in the flow_aggregation_point column. Default is "Energy industry own use".

aggregate_net_finaldemand

the name of the output column containing aggregates of net final demand. Default is "EX_fd_net_IEA.ktoe".

aggregate_gross_finaldemand

the name of the output column containing aggregates of gross final demand. Default is "EX_fd_gross_IEA.ktoe".

Value

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

Details

This function is named with "_IEA", because it is meant to operate on tidy, IEA-style data frames. The function finaldemand_aggregates does the same thing, but it is meant to operate on SUT-style data frames.

Note that all items in .ieadata must be in same units.

This function works similar to summarise: it distills .ieadata to many fewer rows according to the grouping variables. Thus, .ieadata should be grouped prior to passing into this function. Grouping columns are preserved on output.

Examples

library(dplyr) # Works only when all entries are in same units. # When Last.stage is services, different units are involved. # Thus, filter to rows in UKEnergy2000tidy where Last.stage is final or useful. print(names(UKEnergy2000tidy))
#> [1] "Country" "Year" "Ledger.side" #> [4] "Flow.aggregation.point" "Energy.type" "Last.stage" #> [7] "Flow" "Product" "E.dot" #> [10] "Unit"
UKEnergy2000tidy %>% group_by(Country, Year, Energy.type, Last.stage) %>% filter(Last.stage %in% c("Final", "Useful")) %>% finaldemand_aggregates_IEA()
#> # A tibble: 2 x 6 #> # Groups: Country, Year, Energy.type [1] #> Country Year Energy.type Last.stage EX_fd_net_IEA.ktoe EX_fd_gross_IEA.ktoe #> <chr> <dbl> <chr> <chr> <dbl> <dbl> #> 1 GBR 2000 E Final 71750 83275 #> 2 GBR 2000 E Useful 25915. 26375.