Learn R Programming

cograph (version 2.7.2)

mutate_nodes: Add or Change Node Attributes

Description

Evaluates expressions against the node table, with the same centrality and structural vocabulary that select_nodes() offers, and stores the results as node columns.

Usage

mutate_nodes(x, ..., keep_format = FALSE, directed = NULL)

Value

A cograph_network whose node table has the new columns, or the input format when keep_format = TRUE.

Arguments

x

Network input.

...

Named expressions, for example hub = degree > 3 or score = pagerank * 100. Available names are the existing node columns plus every measure and predicate listed under select_nodes.

keep_format

Logical. Return the input format when TRUE. Note that only igraph and cograph_network formats can carry node attributes; a matrix cannot, and the new columns are lost.

directed

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

See Also

mutate_edges, select_nodes, centrality

Examples

Run this code
adj <- matrix(c(0, 1, 1, 1,
                1, 0, 1, 0,
                1, 1, 0, 0,
                1, 0, 0, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")

as.data.frame(mutate_nodes(adj, deg = degree, hub = degree >= 3),
              what = "nodes")

Run the code above in your browser using DataLab