Skip to contents

make_nodelist() makes a node list from the the "to" and "from" columns of the supplied data frame. A node list is a data frame with a "node" column and, optionally, columns for node attributes, where each row is a node.

Usage

make_nodelist(data, 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 from and to arguments below if these columns have names other than "from" and "to".)

node_attributes

an optional data frame with a "node" column and columns for node attributes, where each row represents a node. (See the node argument below if this column has a name other than "node".)

from

the name of the column in data that 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 data that 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_attributes that should be considered the "node" column that contains the names of the nodes. Default is "node".

Value

A netlit_nodelist object, which is a data frame with a node column containing the names of all of the nodes present in data. If node_attributes is supplied, additional columns for node attributes will be present. The "node" attribute contains the name of the "node" column in the returned object, which will always be the first column.

Examples

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

nodelist <- make_nodelist(literature,
                          node_attributes = node_attributes)

str(nodelist)
#> Classes ‘netlit_nodelist’ and 'data.frame':	56 obs. of  2 variables:
#>  $ node: chr  "computers" "number of competitive districts" "partisan advantage" "partisan gerrymandering" ...
#>  $ type: chr  "condition" "goal" "goal" "condition" ...
#>  - attr(*, "node")= chr "node"