sankey | R Documentation |
Creates Sankey diagram from edgelist data.frame.
sankey( df, source.column = "source", target.column = "target", value.column = "value", sort.nodes = c(TRUE, FALSE), text.align = c("outside", "inside"), margin.proportion = 0.2, 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". |
sort.nodes |
Boolean indicating whether to let sankey.js to sort nodes. Defaults to TRUE. If FALSE, nodes will be ordered as they appear in df. |
text.align |
Alignment of node labels. Defaults to "outside". |
margin.proportion |
Proportion of image to devote to margins on both left and right side. Only effective when text.align is "outside". Defaults to 0.2, must be between 0 and 0.5. |
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/sankey-diagram adapted to work with r2d3.
A d3 object as returned by r2d3.
data(energy) sankey(energy)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.