Learn R Programming

cograph (version 1.5.2)

set_nodes: Set Nodes in Cograph Network

Description

Replaces the nodes data frame in a cograph_network object. Automatically updates n_nodes and labels.

Usage

set_nodes(x, nodes_df)

Value

The modified cograph_network object.

Arguments

x

A cograph_network object.

nodes_df

A data frame with node information (id, label columns expected).

See Also

as_cograph, get_nodes, set_edges

Examples

Run this code
mat <- matrix(c(0, 1, 1, 1, 0, 1, 1, 1, 0), nrow = 3)
net <- as_cograph(mat)
new_nodes <- data.frame(id = 1:3, label = c("A", "B", "C"))
net <- set_nodes(net, new_nodes)
get_labels(net)

Run the code above in your browser using DataLab