View source: R/node_edge_list.R
edge_list | R Documentation |
An edge list is a data frame in which each row describes a flow from one entity to another.
Columns in the edge list data frame are From
, To
, Value
, and Product
.
The edge list can be created from the U
, V
, and Y
matrices of an energy conversion chain.
Edge lists is a typical data format for visualization software.
edge_list(
.sutdata = NULL,
R = "R",
U = "U",
V = "V",
Y = "Y",
edge_list = "Edge list",
from = "From",
to = "To",
value = "Value",
product = "Product",
waste = "Waste",
rowtypes = "rowtype",
coltypes = "coltype",
node_id = "node_id",
first_node = 0,
edge_id = "edge_id",
simplify_edges = TRUE
)
.sutdata |
Optionally, a data frame containing columns named with the values of the |
R |
a resource matrix or the name of a column in |
U |
a use matrix or the name of a column in |
V |
a make matrix or the name of a column in |
Y |
a final demand matrix or the name of a column in |
edge_list |
the name of the column in the output data frame containing edge lists.
Or the name of the item in the return list if .sutdata is not specified.
(Default is " |
from |
the name of the edge list column containing source nodes. (Default is " |
to |
the name of the edge list column containing destination nodes. (Default is " |
value |
the name of the edge list column containing magnitudes of the flows. (Default is " |
product |
the name of the edge list column containing the product of the edge list flow. (Default is " |
waste |
the name of the waste product and the destination node for wastes.
Set |
rowtypes |
the name of the rowtypes. (Default is " |
coltypes |
the name of the rowtypes. (Default is " |
node_id |
the base name of node ID columns.
Set |
first_node |
the first node number. (Default is |
edge_id |
the name of the edge ID column.
Set |
simplify_edges |
if |
Optionally, waste streams can be calculated from the U
and V
matrices and
added to the edge list.
Optionally, edges can be simplified when a product has a single source.
In that event, the node named after the product is removed,
and destinations are connected to the sources.
an edge list or a column of edge lists
library(matsbyname)
library(tidyr)
sutmats <- UKEnergy2000mats %>%
spread(key = matrix.name, value = matrix)
# Don't simplify edges and don't include waste edges
el_basic <- edge_list(sutmats, simplify_edges = FALSE)
head(el_basic$`Edge list`[[1]])
tail(el_basic$`Edge list`[[1]])
# Simplify edges and include waste
el <- edge_list(sutmats)
head(el$`Edge list`[[1]])
# Now includes waste edges
tail(el$`Edge list`[[1]])
# Works with single matrices, too.
elmats <- edge_list(R = sutmats$R[[1]], U = sutmats$U[[1]], V = sutmats$V[[1]], Y = sutmats$Y[[1]])
head(elmats[["Edge list"]])
tail(elmats[["Edge list"]])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.