Reputation: 939
Is it possible to make a sankey plot that looks like this in R
?
I've played around with the networkD3
package, which works great if the sum of input = sum of output for each node, but I need a solution which supports bands/links that change in size between time periods.
As far as I can work out, networkD3
does not allow me to do this because you must specify the links with a single value (links have a fixed width/value).
Is there anything out there, preferably for R
, that can do this?
Upvotes: 1
Views: 2156
Reputation: 939
A possible solution to this problem is to use an alluvial plot from the ggalluvial
package.
Source: Weighted sankey / alluvial diagram for visualizing discrete and continuous panel data?
Upvotes: 1
Reputation: 8848
library(networkD3)
links <- read.csv(header = T, text = "
source,target,value
0,1,50
0,2,50
1,3,50
2,4,25
3,5,75
4,5,25
")
nodes <- data.frame(name = c("A", "A", "B", "A", "B", "A"))
sankeyNetwork(links, nodes, "source", "target", "value", "name")
Upvotes: 3