add_node_df: Add nodes from a node data frame to an existing graph object

Description Usage Arguments Value See Also Examples

View source: R/add_node_df.R

Description

With a graph object of class dgr_graph add nodes from a node data frame to that graph.

Usage

1
add_node_df(graph, node_df)

Arguments

graph

A graph object of class dgr_graph.

node_df

A node data frame that is created using create_node_df().

Value

A graph object of class dgr_graph.

See Also

Other Node creation and removal: add_n_node_clones(), add_n_nodes_ws(), add_n_nodes(), add_node_clones_ws(), add_nodes_from_df_cols(), add_nodes_from_table(), add_node(), colorize_node_attrs(), copy_node_attrs(), create_node_df(), delete_nodes_ws(), delete_node(), drop_node_attrs(), join_node_attrs(), layout_nodes_w_string(), mutate_node_attrs_ws(), mutate_node_attrs(), node_data(), recode_node_attrs(), rename_node_attrs(), rescale_node_attrs(), set_node_attr_to_display(), set_node_attr_w_fcn(), set_node_attrs_ws(), set_node_attrs(), set_node_position()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Create an empty graph
graph <- create_graph()

# Create a node data frame (ndf)
ndf <-
  create_node_df(n = 2)

# Add the node data frame to
# the graph object to create
# a graph with nodes
graph <-
  graph %>%
  add_node_df(
    node_df = ndf)

# Inspect the graph's ndf
graph %>% get_node_df()

# Create another ndf
ndf_2 <-
  create_node_df(n = 3)

# Add the second node data
# frame to the graph object
# to add more nodes with
# attributes to the graph
graph <-
  graph %>%
  add_node_df(
    node_df = ndf_2)

# View the graph's internal
# node data frame using the
# `get_node_df()` function
graph %>% get_node_df()

Example output

  id type label
1  1 <NA>  <NA>
2  2 <NA>  <NA>
  id type label
1  1 <NA>  <NA>
2  2 <NA>  <NA>
3  3 <NA>  <NA>
4  4 <NA>  <NA>
5  5 <NA>  <NA>

DiagrammeR documentation built on July 2, 2020, 3:19 a.m.