A convenience function to create PSUT matrices in a data frame
prep_psut.Rd
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_ktoe()
orspecify_TJ()
, depending on the value ofoutput_unit
,calc_S_units()
, and
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.
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)
#> # A tibble: 12 × 13
#> Country Year Method Energy.type Last.stage R U V
#> <chr> <dbl> <chr> <chr> <chr> <list> <list> <list>
#> 1 CHNM 2000 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 2 CHNM 2000 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 3 CHNM 2001 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 4 CHNM 2001 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 5 CHNM 2002 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 6 CHNM 2002 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 7 GBR 2000 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 8 GBR 2000 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 9 GBR 2001 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 10 GBR 2001 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 11 GBR 2002 PCM E Final <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> 12 GBR 2002 PCM E Useful <dbl [1 × 1]> <dbl[…]> <dbl[…]>
#> # ℹ 5 more variables: Y <list>, S_units <list>, U_feed <list>, U_EIOU <list>,
#> # r_EIOU <list>