augment_nodelist: Augment a node list with graph-based node attributes

View source: R/augment_nodelist.R

augment_nodelistR Documentation

Augment a node list with graph-based node attributes

Description

augment_nodelist() augments the supplied node list by adding graph-based measures as node attributes.

Usage

augment_nodelist(nodelist, edgelist = NULL, graph = NULL)

Arguments

nodelist

a "netlit_nodelist" object, the output of a call to make_nodelist.

edgelist

optional; an "netlit_edgelist" object, the output of a call to make_edgelist.

graph

an igraph object; the output of a call to igraph::graph_from_data_frame(edgelist).

Details

When edgelist or graph are supplied, the "degree" node attribute is added, resulting from igraph::degree(graph, mode = "in"). (If graph is not supplied but edgelist is, igraph::graph_from_data_frame() will be run on edgelist first.) In any case, the "betweenness" attribute is added, resulting from igraph::betweenness.

Value

The argument supplied to ndoelist with one or two columns added. When edgelist or graph are supplied, the "degree" column is added. In any case, the "betweenness" column is added.

See Also

review, make_edgelist, make_nodelist

Examples

data("literature")
data("node_attributes")

nodelist <- make_nodelist(literature,
                          node_attributes = node_attributes)

edgelist <- make_edgelist(literature,
                          edge_attributes = c("cites", "cites_empirical"))

nodelist_augmented <- augment_nodelist(nodelist,
                                       edgelist = edgelist)

str(nodelist_augmented)

## Not run: 
#Same results:
graph <- igraph::graph_frm_data_from(edgelist)
nodelist_augmented <- augment_nodelist(nodelist,
                                       graph = graph)

## End(Not run)

judgelord/netlit documentation built on Jan. 3, 2023, 2:42 p.m.