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.
Examples
library(dplyr)
library(magrittr)
#>
#> Attaching package: ‘magrittr’
#> The following object is masked from ‘package:tidyr’:
#>
#> extract
#> The following objects are masked from ‘package:testthat’:
#>
#> equals, is_less_than, not
library(networkD3)
library(tidyr)
UKEnergy2000mats %>%
spread(key = "matrix.name", value = "matrix") %>%
make_sankey() %>%
extract2("Sankey") %>%
extract2(1)