edge2Mat | R Documentation |
Convert network edges to adjacency matrix
edge2Mat(edge, rownm, colnm, direction = TRUE, rmName = FALSE, restValue = 0)
edge |
a data.frame of three columns, the first two columns represent nodes in a network, the third column is the weight. |
rownm |
row names in the final adjacency matrix. All node names must present in either rownm or colnm. |
colnm |
column names in the final adjacency matrix. All node names must present in either rownm or colnm. |
direction |
logic, whether this network is directed, the default is TRUE. |
rmName |
logic, whether to remove row names and column names in the adjacency matrix. |
restValue |
the value to fill in the blank edges. |
An adjacency matrix.
## Not run:
edge = data.frame(c("a", "b", "c"), c("a", "c", "d"), c(1,1,1))
edge2Mat(edge, edge[,1], edge[,2])
nodes = unique(c(as.character(edge[,1]), as.character(edge[,2])))
edge2Mat(edge, nodes, nodes)
edge2Mat(edge, nodes, nodes,direction = FALSE)
edge2Mat(edge, nodes, nodes,direction = FALSE, rmName = TRUE)
edge = data.frame(c(1:3), c(3:5), c(1,1,1))
edge2Mat(edge, edge[,1], edge[,2] )
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.