create_edges {DiagrammeR} | R Documentation

## Create a data frame with edges and their attributes

### Description

Combine several named vectors for edges and their attributes into a data frame, which can be combined with other similarly-generated data frame, or, added to a graph object.

### Usage

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

### Arguments

`from` | a vector of node ID values from which edges are outbound. The vector length must equal to that of the `to` vector.
`to` | a vector of node ID values to which edges are incoming. The vector length must equal to that of the `from` vector.
`rel` | an optional 'rel' description for each edge.
`...` | one or more named vectors for associated attributes.

### Value

a data frame.

### Examples

    ## Not run:
    # Create a simple edge data frame and view results
    edges <-
      create_edges(from = c("a", "b", "c"),
                   to = c("d", "c", "a"),
                   rel = "leading_to")

    render_graph(create_graph(edges_df = edges),
                              output = "visNetwork")

    # Create an edge data frame with additional parameters
    edges <-
      create_edges(from = c("a", "b", "c"),
                   to = c("d", "c", "a"),
                   rel = "leading_to",
                   length = c(50, 100, 250),
                   color = "green",
                   width = c(1, 1, 2))

    render_graph(create_graph(edges_df = edges),
                              output = "visNetwork")

    ## End(Not run)

[Package DiagrammeR version 0.8.2 Index]