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 TJ (terajoules) and changes the units_col from "EJ" to "TJ".

Usage

specify_TJ(
  .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 TJ.

Details

Prior to converting the energy_col from EJ to TJ, 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_TJ()
#> # 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 TJ      868. 
#>  2 GBR      1960 Human females Final   Industry    TJ    15399. 
#>  3 GBR      1960 Human females Final   Services    TJ    28194. 
#>  4 GBR      1960 Human females Primary Agriculture TJ     1400. 
#>  5 GBR      1960 Human females Primary Industry    TJ    24836. 
#>  6 GBR      1960 Human females Primary Services    TJ    45474. 
#>  7 GBR      1960 Human females Useful  Agriculture TJ       41.6
#>  8 GBR      1960 Human females Useful  Industry    TJ      743. 
#>  9 GBR      1960 Human females Useful  Services    TJ      477. 
#> 10 GBR      1960 Human males   Final   Agriculture TJ     4643. 
#> # ℹ 1,088 more rows