set_node_names: Set the node names in a network

Description Usage Arguments Value Examples

View source: R/networks.R

Description

Set the node names in a network

Usage

1
set_node_names(network, node_names)

Arguments

network

The network to modify.

node_names

A vector of strings containing the names for each node in the network. If a numeric vector is provided, the values will be coerced into strings. If 'node_names' is NULL, then the names will default to "1", "2", ..., "p".

Value

The modified network.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Create a random network with 10 nodes. 
nw <- random_network(10)
get_node_names(nw) # Default names are 1, 2, ..., 10.
nw <- set_node_names(nw, paste("node", 1:10, sep = "_"))
get_node_names(nw) # Print out updated node names.
# Modules only contain the indicies to nodes, not the node names
module <- nw$modules[[1]]
get_node_names(module)
# When converting the network to a matrix, node names appear as column names.
adj_matrix <- get_adjacency_matrix(nw)
colnames(adj_matrix) 

tgrimes/SeqNet documentation built on Sept. 1, 2020, 7:50 a.m.