create_edge_df {DiagrammeR} | R Documentation |
Combine several named vectors for edges and their attributes into a data frame, which can be combined with other similarly-generated data frames, or, added to a graph object.
create_edge_df(from, to, rel = NULL, ...)
from |
a vector of node ID values from which
edges are outbound. The vector length must equal
that of the |
to |
a vector of node ID values to which edges
are incoming. The vector length must equal that of
the |
rel |
an optional |
... |
one or more named vectors for associated attributes. |
an edge data frame (edf).
# Create a simple edge data frame (edf) and # view the results edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = "a") # Display the edge data frame edf #> id from to rel #> 1 1 1 4 a #> 2 2 2 3 a #> 3 3 3 1 a # Create an edf with additional edge # attributes (where their classes will be # inferred from the input vectors) edf <- create_edge_df( from = c(1, 2, 3), to = c(4, 3, 1), rel = "a", length = c(50, 100, 250), color = "green", width = c(1, 5, 2)) # Display the edge data frame edf #> id from to rel length color width #> 1 1 1 4 a 50 green 1 #> 2 2 2 3 a 100 green 5 #> 3 3 3 1 a 250 green 2