DiagrammeR (version 1.0.6.1)

create_edge_df: Create an edge data frame

Description

Combine several 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. An edge data frame, or edf, has at least the following columns:

Usage

create_edge_df(from, to, rel = NULL, ...)

Arguments

from

A vector of node ID values from which edges are outbound. The vector length must equal that of the to vector.

to

A vector of node ID values to which edges are incoming. The vector length must equal that of the from vector.

rel

An optional rel label for each edge.

...

One or more vectors for associated edge attributes.

Value

An edge data frame (edf).

Details

  • id (of type integer)

  • from (of type integer)

  • to (of type integer)

  • rel (of type character)

An arbitrary number of additional columns containing aesthetic or data attributes can be part of the edf, so long as they follow the aforementioned columns.

See Also

Other Edge creation and removal: add_edge_clone(), add_edge_df(), add_edges_from_table(), add_edges_w_string(), add_edge(), add_forward_edges_ws(), add_reverse_edges_ws(), copy_edge_attrs(), delete_edges_ws(), delete_edge(), delete_loop_edges_ws(), drop_edge_attrs(), edge_data(), join_edge_attrs(), mutate_edge_attrs_ws(), mutate_edge_attrs(), recode_edge_attrs(), rename_edge_attrs(), rescale_edge_attrs(), rev_edge_dir_ws(), rev_edge_dir(), set_edge_attr_to_display(), set_edge_attrs_ws(), set_edge_attrs()

Examples

Run this code
# NOT RUN {
# 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

# 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

# }

Run the code above in your browser using DataCamp Workspace