Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

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.

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.

Value

An edge data frame (edf).

See Also

Examples

# 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

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.