add_edge_df {DiagrammeR} | R Documentation

## Add edges from an edge data frame to an existing graph object

### Description

With a graph object of class `dgr_graph` add edges from an edge data frame to that graph.

### Usage

    add_edge_df(graph, edge_df)

### Arguments

`graph` | a graph object of class `dgr_graph` that is created using `create_graph`.
`edge_df` | an edge data frame that is created using `create_edges`.

### Value

a graph object of class `dgr_graph`.

### Examples

    ## Not run:
    # Create a graph with nodes and no edges
    nodes <-
      create_nodes(nodes = c("a", "b", "c", "d"),
                   type = "letter",
                   color = c("red", "green", "grey", "blue"),
                   value = c(3.5, 2.6, 9.4, 2.7))

    graph <- create_graph(nodes_df = nodes)

    # Create an edge data frame
    edges <-
      create_edges(from = c("a", "b", "c"),
                   to = c("d", "c", "a"),
                   rel = "leading_to")

    # Add the edge data frame to the graph object to create a
    # graph with both nodes and edges
    graph <-
      add_edge_df(graph = graph, edge_df = edges)

    get_edges(graph, return_type = "vector")
    #> [1] "a -> d" "b -> c" "c -> a"

    ## End(Not run)

[Package DiagrammeR version 0.8.2 Index]