Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

create_node_df

Create a node data frame


Description

Combine several 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. A node data frame, or ndf, has at least the following columns:

Usage

create_node_df(n, type = NULL, label = NULL, ...)

Arguments

n

The total number of nodes to include in the node data frame.

type

An optional type for each node.

label

An optional label for each node.

...

One or more vectors for associated node attributes.

Details

  • id (of type integer)

  • type (of type character)

  • label (of type character)

An arbitrary number of additional columns containing aesthetic or data attributes can be part of the ndf, so long as they follow the aforementioned columns.

Value

A node data frame (ndf).

See Also

Examples

# 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

# 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

DiagrammeR

Graph/Network Visualization

v1.0.6.1
MIT + file LICENSE
Authors
Richard Iannone [aut, cre] (<https://orcid.org/0000-0003-3925-190X>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.