View source: R/network-utils.R
| to_data_frame | R Documentation |
Converts a network to an edge list data frame with columns for source, target, and weight.
to_data_frame(x, directed = NULL)
to_df(x, directed = NULL)
x |
Network input: matrix, igraph, network, cograph_network, or tna object. |
directed |
Logical or NULL. If NULL (default), auto-detect from matrix symmetry. Set TRUE to force directed, FALSE to force undirected. |
A data frame with columns:
from: Source node name/label
to: Target node name/label
weight: Edge weight
to_df, to_igraph, as_cograph
adj <- matrix(c(0, .5, .8, 0,
.5, 0, .3, .6,
.8, .3, 0, .4,
0, .6, .4, 0), 4, 4, byrow = TRUE)
rownames(adj) <- colnames(adj) <- c("A", "B", "C", "D")
# Convert to edge list
to_data_frame(adj)
# Use alias
to_df(adj)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.