Skip to contents

Performs the the energy balance check in a way that is amenable to drake subtargets. Internally, this function uses IEATools::calc_tidy_iea_df_balances(). Grouping is doing internal to this function using the value of grp_vars.

Usage

is_balanced(
  .iea_data,
  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

countries

the countries for which balancing should be checked as strings

country

The name of the country column in IEAData. Default is Country.

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 logical stating whether all products are balanced for the country of interest

Examples

# These data are not balanced, because they are raw.
IEATools::sample_iea_data_path() %>%
  IEATools::load_tidy_iea_df() %>%
  is_balanced(countries = "ZAF")
#> [1] FALSE