Skip to contents

Balances the IEA data in a way that is amenable to drake subtargets. Internally, this function uses IEATools::fix_tidy_iea_df_balances(). Grouping is done internal to this function using the value of grp_vars.

Usage

make_balanced(
  .iea_data,
  max_fix = 6,
  countries,
  country = IEATools::iea_cols$country,
  grp_vars = c(country, IEATools::iea_cols$method, IEATools::iea_cols$energy_type,
    IEATools::iea_cols$last_stage, IEATools::iea_cols$year, IEATools::iea_cols$product)
)

Arguments

.iea_data

A tidy IEA data frame.

max_fix

The maximum allowable energy imbalance to fix. Default is 3.

countries

The countries that should be balanced.

country

See IEATools::iea_cols

grp_vars

the groups that should be checked. Default is c(country, IEATools::iea_cols$method, IEATools::iea_cols$energy_type, IEATools::iea_cols$last_stage, IEATools::iea_cols$product).

Value

A data frame of balanced IEA data.

Examples

IEATools::sample_iea_data_path() %>%
  IEATools::load_tidy_iea_df() %>%
  make_balanced(countries = c("GHA", "ZAF")) %>%
  is_balanced(countries = c("GHA", "ZAF"))
#> [1] TRUE