Make a network object from various input types.

to_network(x, bipartite = FALSE)

Arguments

x

graph data object

bipartite

logical, should x be considered to be bipartite? This overrides the function's default choices.

Value

a network object

Details

The following inputs are supported:

network object

network object

igraph object

igraph object

matrix

This is a base R type matrix. When a matrix is used as input, the function the number of rows is equal to the number of columns. If they are not, the function assumes the matrix refers to a bipartite network. This assumption can be overridden by the bipartite argument.

data.frame

The data.frame contains an edge list. The data.frame requires the first column to contain the senders and the second column contains the receivers. If there are any additional columns, these are considered to be edge attributes.

NOTE: The created network object is considered to be directed. If an undirected network is required, run as.undirected on the output from this function.

The argument bipartite is used to tell the function whether the input represents a bipartite network or not. If it does, then set bipartite to TRUE and the function will attempt to convert the input to a bipartite network. However, the argument is NOT intended to convert a bipartite network to a unipartite network and will NOT do that conversion!

NOTE: as far as we know, this function is the only function that correctly deals with vertex attributes that themselves are lists in the conversion from igraph (which allows lists) to network (which can not deal with lists as attributes).