add_nodes: Add Nodes to a Network

View source: R/wrangle-edit.R

add_nodesR Documentation

Add Nodes to a Network

Description

Appends new nodes, identified by label, to a network. A label that already exists raises a cograph_bad_selection error.

Usage

add_nodes(x, labels, ..., keep_format = FALSE, directed = NULL)

Arguments

x

Network input.

labels

Character vector of labels for the new nodes.

...

Named vectors of node attributes for the new nodes, each of length 1 (recycled) or length(labels). Columns the network does not already have are created and filled with NA for the existing nodes.

keep_format

Logical. Return the input format when TRUE.

directed

Logical or NULL. If NULL (default), auto-detect.

Value

A cograph_network with the new nodes appended (isolated until edges are added), or the input format when keep_format = TRUE.

See Also

remove_nodes, add_edges, mutate_nodes

Examples

add_nodes(regulation_net, labels = "Revise")

cograph documentation built on Nov. 19, 2026, 5:07 p.m.