Load IEA extended energy balance data into tidy format
load_tidy_iea_df.RdLoads an IEA extended energy balance data file in .csv format from disk and converts to a tidy format.
This function bundles several others and relies mostly on default values for arguments:
specify_non_energy_use()(optionally),fix_GHA_industry_electricity() |> fix_GHA_psb() |> fix_COL_electricity_generation()(optionally),
Usage
load_tidy_iea_df(
.iea_file = sample_iea_data_path(),
unit_val = "TJ",
remove_zeroes = TRUE,
specify_non_energy_flows = FALSE,
apply_fixes = FALSE,
override_df = IEATools::override_iso_codes_df,
country = IEATools::iea_cols$country,
pfu_code = IEATools::country_concordance_cols$pfu_code,
iea_name = IEATools::country_concordance_cols$iea_name
)Arguments
- .iea_file
The path of the file to be loaded. Can be a vector of files to be loaded. Default loads example data bundled with the package via
sample_iea_data_path().- unit_val
The units for this file. Default is "TJ".
- remove_zeroes
A logical indicating whether data points with the value
0are to be removed from the output. This argument is passed totidy_iea_df(). Default isTRUE.- specify_non_energy_flows
A logical indicating whether "Non-energy use in xxxxx" Flows should be specified by "Memo: Non-energy use in <
>" entries in the IEA data. Default is FALSE.- apply_fixes
A logical indicating whether fixes should be applied to IEA data. Default is
FALSE.- override_df
A data frame containing columns
pfu_codeandiea_namethat provides 3-letter country codes. SeeIEATools::use_iso_countries(). Default isIEATools::override_iso_codes_df.- country
The name of the country column in the data frames. See
IEATools::iea_cols$country.- pfu_code, iea_name
Names of columns in the override data frame for 3-letter country codes. These arguments are passed to
use_iso_countries(). Defaults are taken fromIEATools::country_concordance_cols.
Details
Each bundled function is called in turn using default arguments. See examples for two ways to achieve the same result.
Examples
# Check the file first
iea_file_OK(sample_iea_data_path())
#> [1] TRUE
# Take a simple approach
simple <- load_tidy_iea_df(specify_non_energy_flows = TRUE)
# Take the complicated approach
complicated <- sample_iea_data_path() |>
iea_df() |>
rename_iea_df_cols() |>
clean_iea_whitespace() |>
remove_agg_memo_flows() |>
use_iso_countries() |>
augment_iea_df() |>
specify_non_energy_use() |>
tidy_iea_df()
# simple and complicated should be exactly the same
all(simple == complicated)
#> [1] FALSE