View source: R/table_functions.R
| assemble_fu_allocation_tables | R Documentation |
This function is used in a drake workflow to assemble completed final-to-useful allocation tables given a set of incomplete allocation tables.
assemble_fu_allocation_tables( incomplete_allocation_tables, exemplar_lists, specified_iea_data, countries, max_year = NULL, country = IEATools::iea_cols$country, year = IEATools::iea_cols$year, exemplars = PFUWorkflow::exemplar_names$exemplars, exemplar_tables = PFUWorkflow::exemplar_names$exemplar_tables, iea_data = PFUWorkflow::exemplar_names$iea_data, incomplete_alloc_tables = PFUWorkflow::exemplar_names$incomplete_alloc_table, complete_alloc_tables = PFUWorkflow::exemplar_names$complete_alloc_table )
incomplete_allocation_tables |
A data frame containing (potentially) incomplete final-to-useful allocation tables. This data frame may be tidy or wide by years. |
exemplar_lists |
A data frame containing |
specified_iea_data |
A data frame containing specified IEA data. |
countries |
A vector of countries for which completed final-to-useful allocation tables are to be assembled. |
max_year |
The latest year for which analysis is desired. Default is |
country, year |
See |
exemplars, exemplar_tables, iea_data, incomplete_alloc_tables, complete_alloc_tables |
See |
Note that this function can accept tidy or wide by year data frames.
The return value is a tidy data frame.
Information from exemplar countries is used to complete incomplete final-to-useful efficiency tables.
See examples for how to construct exemplar_lists.
A tidy data frame containing completed final-to-useful allocation tables.
# Load final-to-useful allocation tables, but eliminate one category of consumption,
# Residential consumption of Primary solid biofuels,
# which will be filled by the exemplar for GHA, ZAF.
incomplete_fu_allocation_tables <- IEATools::load_fu_allocation_data() %>%
dplyr::filter(! (Country == "GHA" & Ef.product == "Primary solid biofuels" &
Destination == "Residential"))
# Show that those rows are gone.
incomplete_fu_allocation_tables %>%
dplyr::filter(Country == "GHA" & Ef.product == "Primary solid biofuels" &
Destination == "Residential")
# But the missing rows of GHA are present in allocation data for ZAF.
incomplete_fu_allocation_tables %>%
dplyr::filter(Country == "ZAF" & Ef.product == "Primary solid biofuels" &
Destination == "Residential")
# Set up exemplar list
el <- tibble::tribble(
~Country, ~Year, ~Exemplars,
"GHA", 1971, c("ZAF"),
"GHA", 2000, c("ZAF"))
el
# Load IEA data
iea_data <- IEATools::load_tidy_iea_df() %>%
IEATools::specify_all()
# Assemble complete allocation tables
completed <- assemble_fu_allocation_tables(incomplete_allocation_tables =
incomplete_fu_allocation_tables,
exemplar_lists = el,
specified_iea_data = iea_data,
countries = "GHA")
# Missing data for GHA has been picked up from ZAF.
completed %>%
dplyr::filter(Country == "GHA" & Ef.product == "Primary solid biofuels" &
Destination == "Residential")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.