Specify Non-energy use when possible
specify_non_energy_use.Rd
For some countries and years, Non-energy use details are supplied
by "Memo:" fields.
We use those details if they exist.
This function assess the energy balance of
replacing "Non-energy use industry/transformation/energy" by
"Non-energy use in <
Usage
specify_non_energy_use(
.iea_df,
country = IEATools::iea_cols$country,
year = IEATools::iea_cols$year,
method = IEATools::iea_cols$method,
energy_type = IEATools::iea_cols$energy_type,
unit = IEATools::iea_cols$unit,
ledger_side = IEATools::iea_cols$ledger_side,
last_stage = IEATools::iea_cols$last_stage,
flow_aggregation_point = IEATools::iea_cols$flow_aggregation_point,
flow = IEATools::iea_cols$flow,
product = IEATools::iea_cols$product,
non_energy_use = IEATools::aggregation_flows$non_energy_use,
non_energy_flows_industry_transformation_energy =
IEATools::non_energy_flows[["non_energy_use_industry_transformation_energy"]],
memo_non_energy_use_in_industry_not_elsewhere_specified =
IEATools::memo_non_energy_flows[["memo_non_energy_use_in_industry_not_elsewhere_specified"]],
non_energy_use_in_industry_not_elsewhere_specified = sub(pattern = paste0("^", memo),
replacement = "", memo_non_energy_use_in_industry_not_elsewhere_specified),
memo = IEATools::memo_aggregation_flow_prefixes$memo,
memo_non_energy_flows_industry =
IEATools::memo_non_energy_flows$memo_non_energy_use_in_industry,
memo_non_energy_use_in = "Memo: Non-energy use in ",
non_energy_use_in = sub(pattern = paste0("^", memo), replacement = "", x =
memo_non_energy_use_in),
total = IEATools::memo_aggregation_product_prefixes$total,
.values = IEATools::template_cols$.values,
.values_summarised = paste0(.values, "_summarised"),
.diff = ".diff",
tol = 1e-06
)
Arguments
- .iea_df
A data frame of IEA data, created by
augment_iea_df()
.- country, year, method, energy_type, unit, ledger_side, last_stage, flow_aggregation_point, flow, product
See
IEATools::iea_cols
.- non_energy_use
- non_energy_flows_industry_transformation_energy
- memo_non_energy_use_in_industry_not_elsewhere_specified
- non_energy_use_in_industry_not_elsewhere_specified
Same as
memo_non_energy_use_in_industry_not_elsewhere_specified
without thememo
prefix.- memo
A string prefix for memo flows. Default is
IEATools::memo_aggregation_flow_prefixes$memo
.- memo_non_energy_flows_industry
- memo_non_energy_use_in
A prefix for specific Non-energy use flows. Default is "Memo: Non-energy use in ".
- non_energy_use_in
Same as
memo_non_energy_use_in
without thememo
prefix.- total
- .values
An internal column name. Default is
IEATools::template_cols$.values
.- .values_summarised
An internal column name. Default is
paste0(.values, "_summarised")
.- .diff
An internal column name. Default is ".diff".
- tol
The tolerance for differences from
0
. Default is1e-6
.
Details
Note that energy balance checks are not performed on the incoming .iea_df
,
but that the specification process itself
ensures that the modifications, themselves, are balanced.
In other words, specifying Non-energy use flows
will not change the energy balance of the incoming .iea_df
data frame.
This function does not promise the resulting data frame
is internally consistent.
Rather, this function should be considered a step along the path to
creating a coherent data frame of IEA data.
Specifically,
this function does not specify aggregation or Memo: flows, so
coherence will be achieved again only after
remove_agg_memo_flows()
is called.
Note that load_tidy_iea_df(specify_non_energy_flows = TRUE)
correctly calls remove_agg_memo_flows()
internally, so
using load_tidy_iea_df()
is preferred to calling specify_non_energy_use()
directly.
Examples
sample_iea_data_path() %>%
iea_df() %>%
rename_iea_df_cols() %>%
clean_iea_whitespace() %>%
augment_iea_df() %>%
specify_non_energy_use()
#> # A tibble: 14,690 × 11
#> Country Method EnergyType LastStage LedgerSide FlowAggregationPoint Flow
#> <chr> <chr> <chr> <chr> <chr> <chr> <chr>
#> 1 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 2 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 3 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 4 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 5 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 6 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 7 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 8 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 9 Ghana PCM E Final Supply Total primary energy su… Prod…
#> 10 Ghana PCM E Final Supply Total primary energy su… Prod…
#> # ℹ 14,680 more rows
#> # ℹ 4 more variables: Product <chr>, Unit <chr>, `1971` <dbl>, `2000` <dbl>