eta_fu_plots_df: Create eta_fu graphs in a data frame

View source: R/graph_functions.R

eta_fu_plots_dfR Documentation

Create eta_fu graphs in a data frame

Description

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

Usage

eta_fu_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 final-to useful efficiency plots are to be created.

plots

The name of the output column containing final-to useful efficiency graphs. 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.

Details

By default, the completed eta_fu 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 final-to useful efficiency graph is constructed for each combination of machine, and eu_product.

Value

A data frame containing a list column of ggplot2 final-to useful efficiency graphs.

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"))

MatthewHeun/SEAPSUTWorkflow documentation built on April 22, 2022, 2:21 p.m.