Calculates total aggregate primary energy from a data frame of IEA data. This function is named with "_IEA", because it is meant to operate on tidy, IEA-style data frames. The function primary_aggregates does the same thing, but it is meant to operate on tidy SUT-style data frames.

primary_aggregates_IEA(
  .ieadata,
  flow = "Flow",
  flow_aggregation_point = "Flow.aggregation.point",
  energy = "E.dot",
  p_industries = c("Production", "Coal mines", "Oil and gas extraction", "Imports",
    "Exports", "International aviation bunkers", "International marine bunkers",
    "Stock changes"),
  eiou = "Energy industry own use",
  aggregate_primary = Recca::aggregate_cols$aggregate_primary_iea
)

Arguments

.ieadata

the data frame containing an IEA table

flow

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

flow_aggregation_point

the name of the column that identifies flow aggregation points. Default is "Flow.aggregation.point".

energy

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

p_industries

a vector of names of primary industries. Default is "c("Coal mines", "Oil and gas extraction", "Production", "Imports", "Exports", "International aviation bunkers", "International marine bunkers", "Stock changes")"

eiou

the string that identifies energy industry own use in the Flow.aggregation.point column. Default is "Energy industry own use".

aggregate_primary

the name of the aggregate primary energy column to be created in the output data frame. Default is "EX_p_IEA.ktoe".

Value

a data frame containing the grouping columns of .ieadata as well as a column named with the value of aggregate_primary.

Details

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 sending into this function. Grouping columns are preserved on output.

Examples

library(dplyr) library(tidyr) r_ind <- resource_industries(UKEnergy2000mats %>% spread(key = matrix.name, value = matrix))[["r_industries"]][[1]] UKEnergy2000tidy %>% group_by(Country, Year, Energy.type, Last.stage) %>% primary_aggregates_IEA(p_industries = r_ind)
#> # A tibble: 4 x 5 #> # Groups: Country, Year, Energy.type [2] #> Country Year Energy.type Last.stage EX_p_IEA.ktoe #> <chr> <dbl> <chr> <chr> <dbl> #> 1 GBR 2000 E Final 93000 #> 2 GBR 2000 E Services 93000 #> 3 GBR 2000 E Useful 93000 #> 4 GBR 2000 X Services 98220