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 )
.ieadata | a data frame with columns of IEA data. |
---|---|
ledger_side | the name of the ledger side column in |
flow_aggregation_point | the name of the flow aggregation point column in |
flow | the name of the column that contains flow information.
Default is " |
energy | the name of the column that contains energy information.
Default is " |
consumption | the identifier for consumption in the |
eiou | the identifier for energy industry own use in the |
aggregate_net_finaldemand | the name of the output column containing aggregates of net final demand.
Default is " |
aggregate_gross_finaldemand | the name of the output column containing aggregates of gross final demand.
Default is " |
a data frame containing grouping columns of .ieadata
and
two additional columns containing net and gross final demand.
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.
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.