Skip to contents

Introduction

After loading IEA data and ensuring that the data are balanced (see the vignette about loading data) and specifying many of the flows (see the vignette about specifying flows), the analyst can prepare for physical supply-use table (PSUT) analysis of an energy conversion chain. This vignette shows how to use the functions in the IEATools package for that purpose.

Adding PSUT matrix names (add_psut_matnames())

The first step to converting the IEA extended energy balance data into PSUT matrices is identifying the matrix in which each datum belongs. The add_psut_matnames() function performs this task. It adds a column named “matnames” (by default but changeable by the user) that contains one of R, U, V, or Y to identify the Resources, Use, Make, or Final demand matrix.

load_tidy_iea_df() %>% 
  add_psut_matnames() %>%
  glimpse()
#> Rows: 403
#> Columns: 12
#> $ Country                <chr> "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA"…
#> $ Method                 <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM"…
#> $ Energy.type            <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E…
#> $ Last.stage             <chr> "Final", "Final", "Final", "Final", "Final", "F…
#> $ Year                   <dbl> 1971, 2000, 1971, 2000, 1971, 2000, 2000, 2000,…
#> $ Ledger.side            <chr> "Supply", "Supply", "Supply", "Supply", "Supply…
#> $ Flow.aggregation.point <chr> "Total primary energy supply", "Total primary e…
#> $ Flow                   <chr> "Production", "Production", "Production", "Prod…
#> $ Product                <chr> "Primary solid biofuels", "Primary solid biofue…
#> $ Unit                   <chr> "TJ", "TJ", "TJ", "TJ", "TJ", "TJ", "TJ", "TJ",…
#> $ E.dot                  <dbl> 87399.9985, 162908.9993, 10472.4010, 23792.3995…
#> $ matnames               <chr> "V", "V", "V", "V", "R", "R", "R", "R", "R", "R…

Note that when a matnames column already exists in .tidy_iea_df, add_psut_matnames() returns the input data frame without modification. This behavior allows other matrix naming conventions.

Add matrix metadata (add_row_col_meta())

The next step is to add information to identify the rows and columns for each datum. The add_row_col_meta() function performs this task by adding rowname, colname, rowtype, and coltype columns which identify the names and types of rows and columns in the PSUT matrices. add_row_col_meta() should be called after calling add_psut_matnames(), because it relies on the the matnames column to determine names and types.

load_tidy_iea_df() %>% 
  add_psut_matnames() %>%
  add_row_col_meta() %>% 
  glimpse()
#> Rows: 403
#> Columns: 16
#> $ Country                <chr> "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA"…
#> $ Method                 <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM"…
#> $ Energy.type            <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E…
#> $ Last.stage             <chr> "Final", "Final", "Final", "Final", "Final", "F…
#> $ Year                   <dbl> 1971, 2000, 1971, 2000, 1971, 2000, 2000, 2000,…
#> $ Ledger.side            <chr> "Supply", "Supply", "Supply", "Supply", "Supply…
#> $ Flow.aggregation.point <chr> "Total primary energy supply", "Total primary e…
#> $ Flow                   <chr> "Production", "Production", "Production", "Prod…
#> $ Product                <chr> "Primary solid biofuels", "Primary solid biofue…
#> $ Unit                   <chr> "TJ", "TJ", "TJ", "TJ", "TJ", "TJ", "TJ", "TJ",…
#> $ E.dot                  <dbl> 87399.9985, 162908.9993, 10472.4010, 23792.3995…
#> $ matnames               <chr> "V", "V", "V", "V", "R", "R", "R", "R", "R", "R…
#> $ rownames               <chr> "Production", "Production", "Production", "Prod…
#> $ colnames               <chr> "Primary solid biofuels", "Primary solid biofue…
#> $ rowtypes               <chr> "Industry", "Industry", "Industry", "Industry",…
#> $ coltypes               <chr> "Product", "Product", "Product", "Product", "Pr…

Note that if all of rowname, colname, rowtype, or coltype columns are already present in .tidy_iea_data, add_row_col_meta() returns the input data frame without modification. This behavior allows other matrix row, column, rowtype, and coltype naming conventions.

If some but not all of rowname, colname, rowtype, and coltype columns are present in in .tidy_iea_data, add_row_col_meta()returns an error.

Collapse to matrices (collapse_to_tidy_psut())

After identifying row and column names and types, the next step is to collapse the data into PSUT matrices. The collapse_to_tidy_psut() function performs this task using the matsindf::collapse_to_matrices() function internally. The matvals column is added to the data frame and contain matrix names for each row of the data frame. collapse_to_tidy_psut() ensures that all entries in each matrix are non-negative.

Tidy_PSUT <- 
load_tidy_iea_df() %>% 
  specify_all() %>% 
  add_psut_matnames() %>% 
  add_row_col_meta() %>% 
  collapse_to_tidy_psut()
Tidy_PSUT %>% 
  glimpse()
#> Rows: 20
#> Columns: 7
#> $ Country     <chr> "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "G…
#> $ Method      <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "P…
#> $ Energy.type <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E"…
#> $ Last.stage  <chr> "Final", "Final", "Final", "Final", "Final", "Final", "Fin…
#> $ Year        <dbl> 1971, 1971, 1971, 1971, 1971, 2000, 2000, 2000, 2000, 2000…
#> $ matnames    <chr> "R", "U_EIOU", "U_feed", "V", "Y", "R", "U_EIOU", "U_feed"…
#> $ matvals     <list> <<matrix[9 x 8]>>, <<matrix[2 x 2]>>, <<matrix[6 x 5]>>, …
class(Tidy_PSUT$matvals[[1]])
#> [1] "matrix" "array"
Tidy_PSUT$matvals[[1]]
#>                                                    Aviation gasoline Crude oil
#> Imports [of Aviation gasoline]                               44.7988       0.0
#> Imports [of Crude oil]                                        0.0000   38359.8
#> Imports [of Kerosene type jet fuel excl. biofuels]            0.0000       0.0
#> Imports [of Lubricants]                                       0.0000       0.0
#> Imports [of Other kerosene]                                   0.0000       0.0
#> Resources [of Hydro]                                          0.0000       0.0
#> Resources [of Primary solid biofuels]                         0.0000       0.0
#> Statistical differences                                       0.0000       0.0
#> Stock changes [of Gas/diesel oil excl. biofuels]              0.0000       0.0
#>                                                    Kerosene type jet fuel excl. biofuels
#> Imports [of Aviation gasoline]                                                    0.0000
#> Imports [of Crude oil]                                                            0.0000
#> Imports [of Kerosene type jet fuel excl. biofuels]                              892.0019
#> Imports [of Lubricants]                                                           0.0000
#> Imports [of Other kerosene]                                                       0.0000
#> Resources [of Hydro]                                                              0.0000
#> Resources [of Primary solid biofuels]                                             0.0000
#> Statistical differences                                                           0.0000
#> Stock changes [of Gas/diesel oil excl. biofuels]                                  0.0000
#>                                                    Lubricants Other kerosene
#> Imports [of Aviation gasoline]                         0.0000         0.0000
#> Imports [of Crude oil]                                 0.0000         0.0000
#> Imports [of Kerosene type jet fuel excl. biofuels]     0.0000         0.0000
#> Imports [of Lubricants]                              755.9979         0.0000
#> Imports [of Other kerosene]                            0.0000        43.7981
#> Resources [of Hydro]                                   0.0000         0.0000
#> Resources [of Primary solid biofuels]                  0.0000         0.0000
#> Statistical differences                                0.0000         0.0000
#> Stock changes [of Gas/diesel oil excl. biofuels]       0.0000         0.0000
#>                                                    Hydro [from Resources]
#> Imports [of Aviation gasoline]                                        0.0
#> Imports [of Crude oil]                                                0.0
#> Imports [of Kerosene type jet fuel excl. biofuels]                    0.0
#> Imports [of Lubricants]                                               0.0
#> Imports [of Other kerosene]                                           0.0
#> Resources [of Hydro]                                              10472.4
#> Resources [of Primary solid biofuels]                                 0.0
#> Statistical differences                                               0.0
#> Stock changes [of Gas/diesel oil excl. biofuels]                      0.0
#>                                                    Primary solid biofuels [from Resources]
#> Imports [of Aviation gasoline]                                                           0
#> Imports [of Crude oil]                                                                   0
#> Imports [of Kerosene type jet fuel excl. biofuels]                                       0
#> Imports [of Lubricants]                                                                  0
#> Imports [of Other kerosene]                                                              0
#> Resources [of Hydro]                                                                     0
#> Resources [of Primary solid biofuels]                                                87400
#> Statistical differences                                                                  0
#> Stock changes [of Gas/diesel oil excl. biofuels]                                         0
#>                                                    Gas/diesel oil excl. biofuels
#> Imports [of Aviation gasoline]                                            0.0000
#> Imports [of Crude oil]                                                    0.0000
#> Imports [of Kerosene type jet fuel excl. biofuels]                        0.0000
#> Imports [of Lubricants]                                                   0.0000
#> Imports [of Other kerosene]                                               0.0000
#> Resources [of Hydro]                                                      0.0000
#> Resources [of Primary solid biofuels]                                     0.0000
#> Statistical differences                                                 822.7020
#> Stock changes [of Gas/diesel oil excl. biofuels]                        476.2987
#> attr(,"rowtype")
#> [1] "Industry"
#> attr(,"coltype")
#> [1] "Product"

Generate S_units matrices (extract_S_units_from_tidy())

A matrix of Products and Units can be obtained from a tidy IEA data frame with the extract_S_units_from_tidy() function.

S_units_df <- load_tidy_iea_df() %>% 
  specify_all() %>% 
  extract_S_units_from_tidy()
S_units_df %>% 
  glimpse()
#> Rows: 4
#> Columns: 6
#> $ Country     <chr> "GHA", "GHA", "ZAF", "ZAF"
#> $ Method      <chr> "PCM", "PCM", "PCM", "PCM"
#> $ Energy.type <chr> "E", "E", "E", "E"
#> $ Last.stage  <chr> "Final", "Final", "Final", "Final"
#> $ Year        <dbl> 1971, 2000, 1971, 2000
#> $ S_units     <list> <<matrix[16 x 1]>>, <<matrix[18 x 1]>>, <<matrix[24 x 1]>>…
S_units_df$S_units[[1]]
#>                                         TJ
#> Aviation gasoline                        1
#> Charcoal                                 1
#> Crude oil                                1
#> Electricity                              1
#> Fuel oil                                 1
#> Gas/diesel oil excl. biofuels            1
#> Hydro                                    1
#> Hydro [from Resources]                   1
#> Kerosene type jet fuel excl. biofuels    1
#> Liquefied petroleum gases (LPG)          1
#> Lubricants                               1
#> Motor gasoline excl. biofuels            1
#> Other kerosene                           1
#> Primary solid biofuels                   1
#> Primary solid biofuels [from Resources]  1
#> Refinery gas                             1
#> attr(,"rowtype")
#> [1] "Product"
#> attr(,"coltype")
#> [1] "Unit"

Putting it all together (prep_psut())

prep_psut() is a convenience function. It converts a tidy IEA data frame that has gone through specify_all() into a PSUT data frame by collapsing the IEA data into PSUT matrices (R, U, V, and Y).

This function bundles several others: 1. add_psut_matnames() 2. add_row_col_meta() 3. collapse_to_tidy_psut()

Furthermore, it extracts S_units matrices using extract_S_units_from_tidy() and adds those matrices to the data frame.

Simple <- load_tidy_iea_df() %>% 
  specify_all() %>% 
  prep_psut() %>% 
  pivot_longer(cols = c(R, U_EIOU, U_feed, V, Y, S_units), names_to = "matnames", values_to = "matvals")
S_units <- load_tidy_iea_df() %>% 
  specify_all() %>% 
  extract_S_units_from_tidy()
Complicated <- load_tidy_iea_df() %>% 
  specify_all() %>% 
  add_psut_matnames() %>% 
  add_row_col_meta() %>% 
  collapse_to_tidy_psut() %>% 
  spread(key = matnames, value = matvals) %>% 
  full_join(S_units, by = c("Method", "Energy.type", "Last.stage", 
                            "Country", "Year")) %>% 
  gather(key = matnames, value = matvals, R, U_EIOU, U_feed, 
         V, Y, S_units)
# Simple and Complicated are same.
full_join(Simple %>% rename(matval_simple = matvals), 
          Complicated %>% rename(matval_complicated = matvals), 
          by = c("Method", "Energy.type", "Last.stage", "Country", "Year", "matnames")) %>% 
  dplyr::mutate(
    same = matsbyname::equal_byname(matval_simple, matval_complicated)
  ) %>% 
  magrittr::extract2("same") %>% 
  as.logical() %>% 
  all()
#> [1] TRUE
Simple %>% 
  glimpse()
#> Rows: 24
#> Columns: 9
#> $ Country     <chr> "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "GHA", "G…
#> $ Method      <chr> "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "PCM", "P…
#> $ Energy.type <chr> "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E", "E"…
#> $ Last.stage  <chr> "Final", "Final", "Final", "Final", "Final", "Final", "Fin…
#> $ Year        <dbl> 1971, 1971, 1971, 1971, 1971, 1971, 2000, 2000, 2000, 2000…
#> $ U           <list> <<matrix[8 x 5]>>, <<matrix[8 x 5]>>, <<matrix[8 x 5]>>, …
#> $ r_EIOU      <list> <<matrix[8 x 5]>>, <<matrix[8 x 5]>>, <<matrix[8 x 5]>>, …
#> $ matnames    <chr> "R", "U_EIOU", "U_feed", "V", "Y", "S_units", "R", "U_EIOU…
#> $ matvals     <list> <<matrix[9 x 8]>>, <<matrix[2 x 2]>>, <<matrix[6 x 5]>>, …
# U_EIOU for Ghana in 1971
Simple$matvals[[5]]
#>                                       Exports to World aviation bunkers [of Aviation gasoline]
#> Aviation gasoline                                                                      44.7988
#> Charcoal                                                                                0.0000
#> Crude oil                                                                               0.0000
#> Electricity                                                                             0.0000
#> Fuel oil                                                                                0.0000
#> Gas/diesel oil excl. biofuels                                                           0.0000
#> Kerosene type jet fuel excl. biofuels                                                   0.0000
#> Liquefied petroleum gases (LPG)                                                         0.0000
#> Lubricants                                                                              0.0000
#> Motor gasoline excl. biofuels                                                           0.0000
#> Other kerosene                                                                          0.0000
#> Primary solid biofuels                                                                  0.0000
#>                                       Residential Stock changes [of Crude oil]
#> Aviation gasoline                          0.0000                       0.0000
#> Charcoal                                4989.5980                       0.0000
#> Crude oil                                  0.0000                     852.4409
#> Electricity                              590.4016                       0.0000
#> Fuel oil                                   0.0000                       0.0000
#> Gas/diesel oil excl. biofuels              0.0000                       0.0000
#> Kerosene type jet fuel excl. biofuels      0.0000                       0.0000
#> Liquefied petroleum gases (LPG)          141.8990                       0.0000
#> Lubricants                                 0.0000                       0.0000
#> Motor gasoline excl. biofuels              0.0000                       0.0000
#> Other kerosene                          3503.9999                       0.0000
#> Primary solid biofuels                 61299.9981                       0.0000
#>                                       Agriculture/forestry
#> Aviation gasoline                                   0.0000
#> Charcoal                                            0.0000
#> Crude oil                                           0.0000
#> Electricity                                        97.2007
#> Fuel oil                                            0.0000
#> Gas/diesel oil excl. biofuels                    1255.7009
#> Kerosene type jet fuel excl. biofuels               0.0000
#> Liquefied petroleum gases (LPG)                     0.0000
#> Lubricants                                          0.0000
#> Motor gasoline excl. biofuels                       0.0000
#> Other kerosene                                      0.0000
#> Primary solid biofuels                              0.0000
#>                                       Commercial and public services
#> Aviation gasoline                                             0.0000
#> Charcoal                                                      0.0000
#> Crude oil                                                     0.0000
#> Electricity                                                 378.0011
#> Fuel oil                                                      0.0000
#> Gas/diesel oil excl. biofuels                               389.6990
#> Kerosene type jet fuel excl. biofuels                         0.0000
#> Liquefied petroleum gases (LPG)                               0.0000
#> Lubricants                                                    0.0000
#> Motor gasoline excl. biofuels                                 0.0000
#> Other kerosene                                                0.0000
#> Primary solid biofuels                                        0.0000
#>                                       Industry not elsewhere specified   Losses
#> Aviation gasoline                                                0.000   0.0000
#> Charcoal                                                         0.000   0.0000
#> Crude oil                                                        0.000   0.0000
#> Electricity                                                    918.002 647.9994
#> Fuel oil                                                      3698.401   0.0000
#> Gas/diesel oil excl. biofuels                                 1645.400   0.0000
#> Kerosene type jet fuel excl. biofuels                            0.000   0.0000
#> Liquefied petroleum gases (LPG)                                  0.000   0.0000
#> Lubricants                                                       0.000   0.0000
#> Motor gasoline excl. biofuels                                    0.000   0.0000
#> Other kerosene                                                   0.000   0.0000
#> Primary solid biofuels                                        6100.000   0.0000
#>                                       Mining and quarrying Non-ferrous metals
#> Aviation gasoline                                   0.0000              0.000
#> Charcoal                                            0.0000              0.000
#> Crude oil                                           0.0000              0.000
#> Electricity                                       698.4001           7102.801
#> Fuel oil                                            0.0000              0.000
#> Gas/diesel oil excl. biofuels                       0.0000              0.000
#> Kerosene type jet fuel excl. biofuels               0.0000              0.000
#> Liquefied petroleum gases (LPG)                     0.0000              0.000
#> Lubricants                                          0.0000              0.000
#> Motor gasoline excl. biofuels                       0.0000              0.000
#> Other kerosene                                      0.0000              0.000
#> Primary solid biofuels                              0.0000              0.000
#>                                       Textile and leather Domestic navigation
#> Aviation gasoline                                  0.0000              0.0000
#> Charcoal                                           0.0000              0.0000
#> Crude oil                                          0.0000              0.0000
#> Electricity                                       61.1985              0.0000
#> Fuel oil                                           0.0000             80.3991
#> Gas/diesel oil excl. biofuels                      0.0000            432.9989
#> Kerosene type jet fuel excl. biofuels              0.0000              0.0000
#> Liquefied petroleum gases (LPG)                    0.0000              0.0000
#> Lubricants                                         0.0000              0.0000
#> Motor gasoline excl. biofuels                      0.0000              0.0000
#> Other kerosene                                     0.0000              0.0000
#> Primary solid biofuels                             0.0000              0.0000
#>                                       Exports [of Fuel oil]
#> Aviation gasoline                                         0
#> Charcoal                                                  0
#> Crude oil                                                 0
#> Electricity                                               0
#> Fuel oil                                               7437
#> Gas/diesel oil excl. biofuels                             0
#> Kerosene type jet fuel excl. biofuels                     0
#> Liquefied petroleum gases (LPG)                           0
#> Lubricants                                                0
#> Motor gasoline excl. biofuels                             0
#> Other kerosene                                            0
#> Primary solid biofuels                                    0
#>                                       Exports to World marine bunkers [of Fuel oil]
#> Aviation gasoline                                                            0.0000
#> Charcoal                                                                     0.0000
#> Crude oil                                                                    0.0000
#> Electricity                                                                  0.0000
#> Fuel oil                                                                   924.6004
#> Gas/diesel oil excl. biofuels                                                0.0000
#> Kerosene type jet fuel excl. biofuels                                        0.0000
#> Liquefied petroleum gases (LPG)                                              0.0000
#> Lubricants                                                                   0.0000
#> Motor gasoline excl. biofuels                                                0.0000
#> Other kerosene                                                               0.0000
#> Primary solid biofuels                                                       0.0000
#>                                           Rail Stock changes [of Fuel oil]
#> Aviation gasoline                       0.0000                      0.0000
#> Charcoal                                0.0000                      0.0000
#> Crude oil                               0.0000                      0.0000
#> Electricity                             0.0000                      0.0000
#> Fuel oil                              200.9999                    321.6007
#> Gas/diesel oil excl. biofuels         432.9989                      0.0000
#> Kerosene type jet fuel excl. biofuels   0.0000                      0.0000
#> Liquefied petroleum gases (LPG)         0.0000                      0.0000
#> Lubricants                              0.0000                      0.0000
#> Motor gasoline excl. biofuels           0.0000                      0.0000
#> Other kerosene                          0.0000                      0.0000
#> Primary solid biofuels                  0.0000                      0.0000
#>                                       Exports to World marine bunkers [of Gas/diesel oil excl. biofuels]
#> Aviation gasoline                                                                                  0.000
#> Charcoal                                                                                           0.000
#> Crude oil                                                                                          0.000
#> Electricity                                                                                        0.000
#> Fuel oil                                                                                           0.000
#> Gas/diesel oil excl. biofuels                                                                   1212.401
#> Kerosene type jet fuel excl. biofuels                                                              0.000
#> Liquefied petroleum gases (LPG)                                                                    0.000
#> Lubricants                                                                                         0.000
#> Motor gasoline excl. biofuels                                                                      0.000
#> Other kerosene                                                                                     0.000
#> Primary solid biofuels                                                                             0.000
#>                                           Road
#> Aviation gasoline                        0.000
#> Charcoal                                 0.000
#> Crude oil                                0.000
#> Electricity                              0.000
#> Fuel oil                                 0.000
#> Gas/diesel oil excl. biofuels         4979.499
#> Kerosene type jet fuel excl. biofuels    0.000
#> Liquefied petroleum gases (LPG)          0.000
#> Lubricants                               0.000
#> Motor gasoline excl. biofuels         8467.200
#> Other kerosene                           0.000
#> Primary solid biofuels                   0.000
#>                                       Exports to World aviation bunkers [of Kerosene type jet fuel excl. biofuels]
#> Aviation gasoline                                                                                            0.000
#> Charcoal                                                                                                     0.000
#> Crude oil                                                                                                    0.000
#> Electricity                                                                                                  0.000
#> Fuel oil                                                                                                     0.000
#> Gas/diesel oil excl. biofuels                                                                                0.000
#> Kerosene type jet fuel excl. biofuels                                                                     1828.602
#> Liquefied petroleum gases (LPG)                                                                              0.000
#> Lubricants                                                                                                   0.000
#> Motor gasoline excl. biofuels                                                                                0.000
#> Other kerosene                                                                                               0.000
#> Primary solid biofuels                                                                                       0.000
#>                                       Non-energy use industry/transformation/energy
#> Aviation gasoline                                                            0.0000
#> Charcoal                                                                     0.0000
#> Crude oil                                                                    0.0000
#> Electricity                                                                  0.0000
#> Fuel oil                                                                     0.0000
#> Gas/diesel oil excl. biofuels                                                0.0000
#> Kerosene type jet fuel excl. biofuels                                        0.0000
#> Liquefied petroleum gases (LPG)                                              0.0000
#> Lubricants                                                                 755.9979
#> Motor gasoline excl. biofuels                                                0.0000
#> Other kerosene                                                               0.0000
#> Primary solid biofuels                                                       0.0000
#>                                       Exports [of Motor gasoline excl. biofuels]
#> Aviation gasoline                                                         0.0000
#> Charcoal                                                                  0.0000
#> Crude oil                                                                 0.0000
#> Electricity                                                               0.0000
#> Fuel oil                                                                  0.0000
#> Gas/diesel oil excl. biofuels                                             0.0000
#> Kerosene type jet fuel excl. biofuels                                     0.0000
#> Liquefied petroleum gases (LPG)                                           0.0000
#> Lubricants                                                                0.0000
#> Motor gasoline excl. biofuels                                           179.1992
#> Other kerosene                                                            0.0000
#> Primary solid biofuels                                                    0.0000
#>                                       Exports [of Other kerosene]
#> Aviation gasoline                                          0.0000
#> Charcoal                                                   0.0000
#> Crude oil                                                  0.0000
#> Electricity                                                0.0000
#> Fuel oil                                                   0.0000
#> Gas/diesel oil excl. biofuels                              0.0000
#> Kerosene type jet fuel excl. biofuels                      0.0000
#> Liquefied petroleum gases (LPG)                            0.0000
#> Lubricants                                                 0.0000
#> Motor gasoline excl. biofuels                              0.0000
#> Other kerosene                                           175.2008
#> Primary solid biofuels                                     0.0000
#> attr(,"rowtype")
#> [1] "Product"
#> attr(,"coltype")
#> [1] "Industry"

Conclusion

Taken together, the functions in this package make it possible to prepare IEA extended energy balance data for use with PSUT analysis techniques. A sequence of three function calls is all that is required.

wide_PSUT_mats <- load_tidy_iea_df() %>% 
  specify_all() %>% 
  prep_psut()
wide_PSUT_mats %>% 
  glimpse()
#> Rows: 4
#> Columns: 13
#> $ Country     <chr> "GHA", "GHA", "ZAF", "ZAF"
#> $ Method      <chr> "PCM", "PCM", "PCM", "PCM"
#> $ Energy.type <chr> "E", "E", "E", "E"
#> $ Last.stage  <chr> "Final", "Final", "Final", "Final"
#> $ Year        <dbl> 1971, 2000, 1971, 2000
#> $ Y           <list> <<matrix[12 x 21]>>, <<matrix[13 x 20]>>, <<matrix[18 x 26…
#> $ S_units     <list> <<matrix[16 x 1]>>, <<matrix[18 x 1]>>, <<matrix[24 x 1]>>…
#> $ R           <list> <<matrix[9 x 8]>>, <<matrix[13 x 12]>>, <<matrix[6 x 6]>>,…
#> $ U           <list> <<matrix[8 x 5]>>, <<matrix[7 x 5]>>, <<matrix[11 x 11]>>,…
#> $ U_feed      <list> <<matrix[6 x 5]>>, <<matrix[5 x 5]>>, <<matrix[9 x 11]>>, …
#> $ U_EIOU      <list> <<matrix[2 x 2]>>, <<matrix[2 x 2]>>, <<matrix[2 x 3]>>, …
#> $ r_EIOU      <list> <<matrix[8 x 5]>>, <<matrix[7 x 5]>>, <<matrix[11 x 11]>>…
#> $ V           <list> <<matrix[5 x 11]>>, <<matrix[5 x 11]>>, <<matrix[11 x 20]…