View source: R/list_to_matrix.R
| list_to_matrix | R Documentation |
Convert an edge list to a matrix. Can handle unipartite and bipartite networks.
list_to_matrix(
x,
directed = FALSE,
bipartite = TRUE,
group_names = c("set_cols", "set_rows"),
node_metadata = NULL
)
x |
An edge list of the format |
directed |
Is the network directed? |
bipartite |
Is network bipartite? |
group_names |
For bipartite networks: name of the groups in the columns and rows, respectively (e.g., parasites and hosts). |
node_metadata |
Following the igraph method of |
It is also possible to add node attributes. For this, it uses
igraph. The first column in the node_metadata data frame should have
the names of the nodes in the edge list.
A monolayer object.
Functions create_monolayer_network, monolayer and graph_from_data_frame from igraph.
library(dplyr)
network <- load_emln(17)
nodes <- network$nodes
links<-subset(network$extended_ids %>% filter(layer_from==1), select=c(node_from, node_to, weight))
list_to_matrix(links, directed = TRUE, bipartite = FALSE, node_metadata = nodes)
# See examples in:
# https://emln.ecomplab.com/monolayer.html#Unipartite
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.