make_sankey: Make a Sankey diagram

View source: R/sankey.R

make_sankeyR Documentation

Make a Sankey diagram

Description

A Sankey diagram is a flow diagram in which the width of the lines is proportional to the rate of energy flow. Sankey diagrams are a helpful way to visualize energy flows in an energy conversion chain (ECC). This function takes a matrix description of an ECC and produces a Sankey diagram.

Usage

make_sankey(
  .sutmats = NULL,
  R = Recca::psut_cols$R,
  U = Recca::psut_cols$U,
  V = Recca::psut_cols$V,
  Y = Recca::psut_cols$Y,
  simplify_edges = TRUE,
  sankey = Recca::sankey_cols$sankey,
  ...
)

Arguments

.sutmats

an optional wide-by-matrices data frame

R, U, V, Y

See Recca::psut_cols.

simplify_edges

a boolean which tells whether edges should be simplified. Applies to every row of .sutmats if .sutmats is specified.

sankey

See Recca::sankey_cols.

...

Arguments passed to networkD3::sankeyNetwork(), mostly for formatting purposes.

Details

At present, this function uses the networkD3 package to draw the Sankey diagram.

If any of R, U, V, or Y is NA, NA is returned.

Value

a Sankey diagram

Examples

library(dplyr)
library(magrittr)
library(networkD3)
library(tidyr)
UKEnergy2000mats %>%
  spread(key = "matrix.name", value = "matrix") %>%
  make_sankey() %>%
  extract2("Sankey") %>%
  extract2(1)

MatthewHeun/Recca documentation built on Feb. 9, 2024, 6:18 p.m.