get_node_df: Get a node data frame from a graph

Description Usage Arguments Value Examples

View source: R/get_node_df.R

Description

From a graph, obtain a node data frame with all current node attributes.

Usage

1
get_node_df(graph)

Arguments

graph

a graph object of class dgr_graph.

Value

a node data frame.

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
36
# Create a graph using several piped functions
graph <-
  create_graph() %>%
  add_n_nodes(
    n = 1,
    type = "a") %>%
  select_last_nodes_created() %>%
  add_n_nodes_ws(
    n = 5,
    direction = "from",
    type = "b") %>%
  select_nodes_by_id(nodes = 1) %>%
  set_node_attrs_ws(
    node_attr = value,
    value = 25.3) %>%
  clear_selection() %>%
  select_nodes_by_id(nodes = 2:4) %>%
  set_node_attrs_ws(
    node_attr = color,
    value = "grey70") %>%
  invert_selection() %>%
  set_node_attrs_ws(
    node_attr = color,
    value = "grey80") %>%
  clear_selection()

# Get the graph's internal node
# data frame (ndf)
get_node_df(graph)
#>   id type label value  color
#> 1  1    a  <NA>  25.3 grey80
#> 2  2    b  <NA>    NA grey70
#> 3  3    b  <NA>    NA grey70
#> 4  4    b  <NA>    NA grey70
#> 5  5    b  <NA>    NA grey80
#> 6  6    b  <NA>    NA grey80

DiagrammeR documentation built on Sept. 7, 2017, 1:06 a.m.