prep_psut: A convenience function to create PSUT matrices in a data...

View source: R/psut.R

prep_psutR Documentation

A convenience function to create PSUT matrices in a data frame

Description

Starting from human and animal muscle work data frames, this function bundles several functions to create a data frame of PSUT matrices. The bundled functions are:

  • specify_energy_type_method(),

  • specify_product(),

  • specify_ktoe() or specify_TJ(), depending on the value of output_unit,

  • MWTools::specify_primary_production(),

  • specify_useful_products(),

  • specify_fu_machines(),

  • specify_last_stages(),

  • MWTools::add_row_col_meta(),

  • MWTools::collapse_to_psut(),

  • calc_S_units(), and

  • calc_U_feed_U_eiou_r_eiou().

Usage

prep_psut(
  .hmw_df,
  .amw_df,
  matrix_class = c("matrix", "Matrix"),
  output_unit = c("TJ", "ktoe"),
  unit = IEATools::iea_cols$unit,
  R = IEATools::psut_cols$R,
  U = IEATools::psut_cols$U,
  V = IEATools::psut_cols$V,
  Y = IEATools::psut_cols$Y,
  s_units = IEATools::psut_cols$s_units,
  U_feed = IEATools::psut_cols$U_feed,
  U_eiou = IEATools::psut_cols$U_eiou,
  r_eiou = IEATools::psut_cols$r_eiou
)

Arguments

.hmw_df

A data frame produced by calc_hmw_pfu().

.amw_df

A data frame produced by calc_amw_pfu().

matrix_class

The type of matrix to be created, one of "matrix" or "Matrix". Default is "matrix".

output_unit

A string of length one that specifies the output unit. One of "TJ" or "ktoe" for terajoules or kilotons of oil equivalent.

unit, R, U, V, Y, s_units, U_feed, U_eiou, r_eiou

Column names. See IEATools::psut_cols.

Details

Default values are assumed for function arguments.

The "Unit" column is deleted after the "S_units" column is created.

Value

A data frame of muscle work PSUT matrices.

Examples

ilo_working_hours_data <- read.csv(file = MWTools::ilo_working_hours_test_data_path())
ilo_employment_data <- read.csv(file = MWTools::ilo_employment_test_data_path())
hmw_data <- prepareRawILOData(ilo_working_hours_data = ilo_working_hours_data,
                              ilo_employment_data = ilo_employment_data)
hmw_df <- hmw_data %>%
  calc_hmw_pfu() %>%
  # Keep only a few years for speed.
  dplyr::filter(Year %in% 2000:2002)
amw_df <- amw_test_data_path() %>%
  read.csv() %>%
  calc_amw_pfu() %>%
  # Keep only a few years for speed.
  dplyr::filter(Year %in% 2000:2002)
prep_psut(hmw_df, amw_df)

EnergyEconomyDecoupling/MWTools documentation built on April 14, 2025, 9:27 a.m.