tidy_iea_df: Creates a tidy IEA data frame

View source: R/initialize.R

tidy_iea_dfR Documentation

Creates a tidy IEA data frame

Description

Data from the IEA have years in columns, but the tidy data format requires one row for each datum. This function uses tidyr::pivot_longer() to make an IEA data frame tidy.

Usage

tidy_iea_df(
  .iea_df,
  col_names = IEATools::iea_cols,
  year = col_names$year,
  e_dot = col_names$e_dot,
  method = col_names$method,
  last_stage = col_names$last_stage,
  country = col_names$country,
  ledger_side = col_names$ledger_side,
  flow_aggregation_point = col_names$flow_aggregation_point,
  energy_type = col_names$energy_type,
  unit = col_names$unit,
  flow = col_names$flow,
  product = col_names$product,
  remove_zeroes = TRUE
)

Arguments

.iea_df

A IEA data frame whose columns have been renamed by rename_iea_df_cols().

col_names

A list of column names in IEA data frames. Default is IEATools::iea_cols.

year

The name of the year column created in .iea_df by this function. Default is col_names$year.

e_dot

The name of the energy/exergy value column created in .iea_df by this function. Default is col_names$e_dot.

method

The name of the method column created in .iea_df by this function. Default is col_names$method.

last_stage

The name of the last stage column created in .iea_df by this function. Default is col_names$last_stage.

country

The name of the country column in .iea_df. Default is col_names$country.

ledger_side

The name of the ledger side in .iea_df. Default is col_names$ledger_side.

flow_aggregation_point

The name of the flow aggregation point column in .iea_df. Default is col_names$flow_aggregation_point.

energy_type

The name of the energy type column in .iea_df. Default is col_names$energy_type.

unit

The name of the unit column in .iea_df. Default is col_names$unit.

flow

The name of the flow column in .iea_df. Default is col_names$flow.

product

The name of the product column in .iea_df. Default is col_names$product.

remove_zeroes

A logical indicating whether data points with the value 0 are to be removed from the output. Default is TRUE.

Details

Default argument values assume that rename_iea_df_cols() has been called on .iea_df.

Value

A tidy version of .iea_df containing new columns year and e_dot and, optionally, 0 values removed.

Examples

sample_iea_data_path() %>% 
  iea_df() %>%
  rename_iea_df_cols() %>% 
  remove_agg_memo_flows() %>% 
  use_iso_countries() %>% 
  augment_iea_df() %>% 
  tidy_iea_df()

MatthewHeun/IEATools documentation built on Feb. 6, 2024, 3:29 p.m.