I would like to make a modified sankey plot in R, where it is possible to have several edges between nodes, to identify different paths. It is a bit hard to explain so I made sample picture in ppt :)
I know it is ugly :) but my point is that I would like to be able to make to edges between A and B1, and clearly indicate which edge belongs to the path going to C1 and C2.
I tried sankeyPlot from the rCharts-packages, however I could only get two columns of nodes.
I have also tried the riverplot-packages, but here I can not make two edges between the same nodes.
You can use DiagrammeR with graphviz graph and HTML table labels:
library(DiagrammeR)
g1 <-
'digraph structs {
B1_node [label=<
<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0">
<TR><TD PORT="One">B One</TD></TR>
<TR><TD PORT="Two">B Two</TD></TR>
</TABLE>
> ];
A -> B1_node:One;
A -> B1_node:Two;
A -> B2;
B1_node:One -> C1;
B1_node:Two -> C2;
B2 -> C3;
rankdir=LR
}'
grViz(g1)
See DiagrammeR/graphviz and graphviz/node shapes documentation.
You could use Sankey diagram but you have to split your node B1:
links <- data.frame(
source = c("A", "A", "B1", "B1", "A", "B1a", "B1b", "B2" ),
target =c("B1", "B1", "B1a", "B1b", "B2", "C1", "C2", "C3"),
value = c(20, 20, 20, 20, 30, 20, 20, 30)
)