View source: R/df.to.adjacency.R
df.to.adjacency | R Documentation |
Creates an adjacency matrix from an edge list data.frame.
df.to.adjacency( df, source.column = "source", target.column = "target", value.column = "value" )
df |
data.frame containing edge data |
source.column |
Name of column containing source nodes. Defaults to "source". |
target.column |
Name of column containing target nodes. Defaults to "target". |
value.column |
Name of column containing edge values. Defaults to "value". |
A list with two components:
matrix |
Adjacency matrix |
labels |
Names of nodes, in same order as rows/columns of adjacency matrix |
labels = c("spam", "eggs", "foo", "bar") df = data.frame(source = rep(labels, each = 4), target = rep(labels, times = 4), value = c(11975, 5871, 8916, 2868, 1951, 10048, 2060, 6171, 8010, 16145, 8090, 8045, 1013, 990, 940, 6907)) df.to.adjacency(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.