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

add_node_df

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


Description

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

Usage

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

Examples

# 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()

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.