chord | R Documentation |
Creates chord diagram from edgelist data.frame.
chord( df, source.column = "source", target.column = "target", value.column = "value", adjacency.matrix = NULL, labels = NULL, edge.color = c("path", "input", "output", "none"), color.scheme = c("Spectral", names(d3po::color.schemes)), width = NULL, height = NULL, viewer = c("internal", "external", "browser") )
df |
data.frame containing edgelist 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". |
adjacency.matrix |
Adjancency matrix of edge weights, as an alternative to edge list. |
labels |
Node names corresponding to rows/columns of adjacency.matrix. |
edge.color |
Method of coloring edges. The value "path" will create a gradient between two nodes. Defaults to "path". |
color.scheme |
Color scheme to use in visualization. See color.schemes for more details. |
width |
Desired width for output widget. |
height |
Desired height for output widget. |
viewer |
"internal" to use the RStudio internal viewer pane for output; "external" to display in an external RStudio window; "browser" to display in an external browser. |
Utilizes a script similar to https://observablehq.com/@d3/chord-diagram adapted to work with r2d3.
A d3 object as returned by r2d3.
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)) chord(df)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.