# NOT RUN {
# Create a node data frame (ndf) where the labels
# are equivalent to the node ID values (this is not
# recommended); the `label` and `type` node
# attributes will always be a `character` class
# whereas `id` will always be an `integer`
node_df <-
create_node_df(
n = 4,
type = c("a", "a", "b", "b"),
label = TRUE)
# Display the node data frame
node_df
#> id type label
#> 1 1 a 1
#> 2 2 a 2
#> 3 3 b 3
#> 4 4 b 4
# Create an ndf with distinct labels and
# additional node attributes (where their classes
# will be inferred from the input vectors)
node_df <-
create_node_df(
n = 4,
type = "a",
label = c(2384, 3942, 8362, 2194),
style = "filled",
color = "aqua",
shape = c("circle", "circle",
"rectangle", "rectangle"),
value = c(3.5, 2.6, 9.4, 2.7))
# Display the node data frame
node_df
#> id type label style color shape value
#> 1 1 a 2384 filled aqua circle 3.5
#> 2 2 a 3942 filled aqua circle 2.6
#> 3 3 a 8362 filled aqua rectangle 9.4
#> 4 4 a 2194 filled aqua rectangle 2.7
# }
Run the code above in your browser using DataCamp Workspace