add_node {DiagrammeR} | R Documentation |
With a graph object of class dgr_graph
, add a new node
of a specified type to extant nodes within the graph.
add_node(graph, type = NULL, label = TRUE, from = NULL, to = NULL, node = NULL)
graph |
a graph object of class |
type |
an optional string that describes the entity type for the node to be added. |
label |
a character object for supplying an optional label to the node.
Setting to |
from |
an optional vector containing node IDs from which edges will be directed to the new node. |
to |
an optional vector containing node IDs to which edges will be directed from the new node. |
node |
an optional node ID for the newly connected node. If no value is provided, a node ID will assigned as a monotonically increasing integer. |
a graph object of class dgr_graph
.
## Not run: # Create an empty graph graph <- create_graph() # Add two nodes graph <- add_node(graph) graph <- add_node(graph) get_nodes(graph) #> [1] "1" "2" # Add a node with 'type' defined graph <- add_node(graph, type = "person") get_node_df(graph) #> nodes type label #> 1 1 1 #> 2 2 2 #> 3 3 person 3 ## End(Not run)