Skip to contents

This function adds a column of ggplot2 graphs to a completed phi_u tables data frame. The graphs are stored in a list column named plots.

Usage

phi_u_plots_df(
  .df,
  countries,
  plots = "Plots",
  country = IEATools::iea_cols$country,
  year = IEATools::iea_cols$year,
  .values = IEATools::template_cols$.values,
  machine = IEATools::template_cols$machine,
  eu_product = IEATools::template_cols$eu_product,
  machine_eu_product = paste0(machine, "_", eu_product)
)

Arguments

.df

The completed final-to useful efficiency tables data frame. Which contains both eta.fu and phi.u values. Default is drake::readd(PFUWorkflow::target_names$CompletedEfficiencyTables, path = cache_path, character_only = TRUE).

countries

The countries for which exergy-to-energy ratio plots are to be created.

plots

The name of the output column containing exergy-to-energy ratio graph. Default is "plots".

country

See IEATools::iea_cols.

year

See IEATools::iea_cols. Passed to alloc_graph().

.values, machine, eu_product

See IEATools::template_cols. Passed to eta_fu_graph().

machine_eu_product

The name of a combined machine and eu_product column.

Value

A data frame containing a list column of ggplot2 exergy-to-energy ratio graphs.

Details

By default, the completed phi_u tables data frame is read from a drake cache.

The data frame is grouped by machine, and eu_product and nested prior to making the graphs, meaning that one exergy-to-energy ratio graph is constructed for each combination of machine, and eu_product.

Examples

# Make a simple data frame with the expected structure.
alloc_table <- tibble::tribble(~Country, ~Year, ~Ef.product, ~Destination,
                               ~.values, ~Machine, ~Eu.product,
                               "GHA", 1971, "Gasoline", "Transport",
                               0.5, "Cars", "MD",
                               "GHA", 1971, "Gasoline", "Transport",
                               0.5, "Trucks", "MD",
                               "GHA", 2020, "Gasoline", "Transport",
                               0.2, "Cars", "MD",
                               "GHA", 2020, "Gasoline", "Transport",
                               0.8, "Trucks", "MD",
                               "ZAF", 1971, "Gasoline", "Transport",
                               0.5, "Cars", "MD",
                               "ZAF", 1971, "Gasoline", "Transport",
                               0.5, "Trucks", "MD",
                               "ZAF", 2020, "Gasoline", "Transport",
                               0.3, "Cars", "MD",
                               "ZAF", 2020, "Gasoline", "Transport",
                               0.7, "Trucks", "MD")
alloc_plots_df(alloc_table, c("GHA", "ZAF"))
#> # A tibble: 2 × 5
#> # Groups:   Country, Ef.product, Destination [2]
#>   Country Ef.product Destination Data             Plots 
#>   <chr>   <chr>      <chr>       <list>           <list>
#> 1 GHA     Gasoline   Transport   <tibble [4 × 4]> <gg>  
#> 2 ZAF     Gasoline   Transport   <tibble [4 × 4]> <gg>