add_n_nodes {DiagrammeR} | R Documentation |
Add n new nodes to a graph object of
class dgr_graph
. Optionally, set node
type
values for the new nodes.
add_n_nodes(graph, n, set_node_type = NULL)
graph |
a graph object of class
|
n |
the number of new nodes to add to the graph. |
set_node_type |
an optional string to apply a
|
a graph object of class dgr_graph
.
library(magrittr) # Create an empty graph and add 5 nodes to it; these # nodes will be given ID values from 1 to 5 graph <- create_graph() %>% add_n_nodes(5) # Get the graph's nodes graph %>% get_nodes #> [1] "1" "2" "3" "4" "5"