View source: R/create_monolayer_network.R
| create_monolayer_network | R Documentation |
Automatically identifies if the input is a matrix or an edge list and creates
a monolayer object.
create_monolayer_network(
x,
directed = NULL,
bipartite = NULL,
group_names = c("set_cols", "set_rows"),
node_metadata = NULL
)
x |
input data in the format of a matrix, edge list or an igraph object. |
directed |
Is the network directed? |
bipartite |
Is the network bipartite? Ignored when the input is an igraph object. |
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 |
Converts between edge list and matrix formats and creates a
monolayer object. It a wrapper function for
list_to_matrix, matrix_to_list_unipartite, matrix_to_list_bipartite. Node metadata can only be included with an edge list input.
A monolayer object.
list_to_matrix, matrix_to_list_unipartite, monolayer.
library(igraph)
# A bipartite network from package bipartte
x <- create_monolayer_network(bipartite::memmott1999, bipartite = TRUE,
directed = FALSE, group_names = c('Animals','Plants'))
# A bipartite network as an igraph object
# Generate a random bipartite network in igraph
g <- igraph::sample_bipartite(10,16,p=0.3, type = 'gnp', directed = TRUE, mode = 'in')
V(g)$name <- letters # name the nodes
V(g)$gender <- sample(c('F','M'), size = 26, replace = TRUE) # Add a node attribute
E(g)$weight=runif(ecount(g)) # Add edge weights
plot(g, layout=layout.bipartite)
create_monolayer_network(g, group_names = c('Parasites','Hosts'))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.