Skip to contents

Primary-final-useful (PFU) data from calc_hmw_pfu() and calc_amw_pfu() are in EJ. This function converts entries in the energy_col from EJ (exajoules) to ktoe and changes the units_col from "EJ" to "ktoe".

Usage

specify_ktoe(
  .df,
  energy_col = MWTools::mw_cols$e_dot,
  units_col = MWTools::mw_cols$unit
)

Arguments

.df

A data frame with units_col and energy_col columns.

energy_col, units_col

See MWTools::mw_constants.

Value

.df with energy column converted from EJ to ktoe.

Details

Prior to converting the energy_col from EJ to ktoe, the units_col is verified to contain only "EJ". An error is thrown if any units_col entry is not in EJ.

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_data %>%
  calc_hmw_pfu() %>%
  specify_ktoe()
#> # A tibble: 1,098 × 7
#>    Country  Year Species       Stage   Sector      Unit     E.dot
#>    <chr>   <dbl> <chr>         <chr>   <chr>       <chr>    <dbl>
#>  1 GBR      1960 Human females Final   Agriculture ktoe    20.7  
#>  2 GBR      1960 Human females Final   Industry    ktoe   368.   
#>  3 GBR      1960 Human females Final   Services    ktoe   673.   
#>  4 GBR      1960 Human females Primary Agriculture ktoe    33.4  
#>  5 GBR      1960 Human females Primary Industry    ktoe   593.   
#>  6 GBR      1960 Human females Primary Services    ktoe  1086.   
#>  7 GBR      1960 Human females Useful  Agriculture ktoe     0.994
#>  8 GBR      1960 Human females Useful  Industry    ktoe    17.8  
#>  9 GBR      1960 Human females Useful  Services    ktoe    11.4  
#> 10 GBR      1960 Human males   Final   Agriculture ktoe   111.   
#> # ℹ 1,088 more rows