
Create an edgelist and nodelist augmented with igraph network statistics
review.RdProcesses a dataframe (and edgelist) by adding network statistics and producing a nodelist and an igraph graph object for use in subsequent analysis.
Usage
review(data, edge_attributes = NULL,
node_attributes = NULL, from = "from",
to = "to", node = "node")Arguments
- data
a data set with a "from" column and a "to" column, where each row represents a directed edge. (See the
fromandtoarguments below if these columns have names other than"from"and"to".)- edge_attributes
an optional character vector of the names of columns in
datacontaining edge attributes. Specified columns will be retained in the augmented edgelist. Others will be dropped. Seemake_edgelist.- node_attributes
an optional data frame with columns "node" as well as any node attributes. Node attribute names may not be the same as any edge attribute names. See
make_nodelist- from
the name of the column in
datathat should be considered the "from" column, i.e., representing the nodes from which directed edges emanate. Default is"from".- to
the name of the column in
datathat should be considered the "to" column, i.e., representing the nodes to which directed edges point. Default is"to".- node
the name of the column in
node_attributesthat should be considered the "node" column that contains the names of the nodes. These names should correspond to node names in the "to" or "from" columns of the main data. Default is"node".
Value
A netlit_review object, which contains three elements:
- edgelist
an edge list with the selected edge attributes and the
edge_betweennesscolumn added- nodelist
a node list with the included node attributes and the
degree_in,degree_out,degree_totalandbetweennesscolumns added- graph
an
igraphgraph object created from theedgelistandnodelist
There is a print method that reports some basic summaries of the object.
Details
review() performs the tasks of make_edgelist, make_nodelist, and augment_nodelist all in one step. First, it creates a pared down version of data containing only the from, to, and edge_attributes columns, and an added "edge_betweenness" column containing edge betweennesses as produced by igraph::edge_betweenness(). Next, it creates a node list by merging the attrbiutes with the unique nodes present in data. Next, it augments the node list by adding a "degree" column resulting from igraph::degree with mode = "in" and a "betweenness" column resulting from igraph::betweenness. Finally, it produces a graph from the edge list and node list using igraph::graph_from_data_frame.
All but the last step can be performed individually using the netlit functions mentioned above.
Examples
data("literature")
lit <- review(literature)
lit
#> A netlit_review object with the following components:
#>
#> $edgelist
#> - 69 edges
#> - edge attributes: edge_betweenness
#> $nodelist
#> - 56 nodes
#> - node attributes: degree_in, degree_out, degree_total, betweenness
#> $graph
#> an igraph object
data("node_attributes")
lit <- review(literature,
edge_attributes = c("cites", "cites_empirical"),
node_attributes = node_attributes)
lit
#> A netlit_review object with the following components:
#>
#> $edgelist
#> - 69 edges
#> - edge attributes: cites, cites_empirical, edge_betweenness
#> $nodelist
#> - 56 nodes
#> - node attributes: type, degree_in, degree_out, degree_total, betweenness
#> $graph
#> an igraph object