Create a data frame with nodes and their attributes

Share:

Description

Combine several named vectors for nodes and their attributes into a data frame, which can be combined with other similarly-generated data frames, or, added to a graph object.

Usage

1
create_nodes(nodes, type = NULL, label = nodes, ...)

Arguments

nodes

the node ID value(s) for the node(s) to be created.

type

an optional type label for each node.

label

an optional label for each node.

...

one or more named vectors for associated attributes.

Value

a node data frame (ndf).

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
# Create a node data frame (ndf)
nodes <-
  create_nodes(
    nodes = 1:4,
    type = "a",
    label = TRUE,
    style = "filled",
    color = "aqua",
    shape = c("circle", "circle",
              "rectangle", "rectangle"),
    value = c(3.5, 2.6, 9.4, 2.7))

# Display the `nodes` ndf
nodes
#>   nodes type label  style color     shape value
#> 1     1    a     1 filled  aqua    circle   3.5
#> 2     2    a     2 filled  aqua    circle   2.6
#> 3     3    a     3 filled  aqua rectangle   9.4
#> 4     4    a     4 filled  aqua rectangle   2.7

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.