0

Dataset:

source <- c(
  'C-new (Bank)','D-new (Bank)','E-new (Bank)',
  'A-Orig (non-Bank)','B-Orig (Bank)','B-Orig (Bank)',
  'B-Orig (Bank)','B-Orig (Bank)','B-Orig (Bank)'
)

target <- c(
  'B-Same-name (non-Bank)','B-Same-name (non-Bank)','A-Same-name (non-Bank)',
  'B-Orig (Bank)','B-Same-name (non-Bank)','A-Same-name (non-Bank)',
  'C-Same-name (non-Bank)','D-Same-name (non-Bank)','E-Same-name (non-Bank)'
)

date <- c('2-jan-2022','2-jan-2022','2-jan-2022','3-jan-2022','4-jan-2022','4-jan-2022','5-jan-2022','6-jan-2022','7-jan-2022')
aggamt <- c(5000,3000,2000,10000,2000,2000,2000,2000,2000)

links <- data.frame(source, target, date, aggamt)

With the code provided by R Graph Gallery

nodes <- data.frame(
  name=c(as.character(links$source), 
         as.character(links$target)) %>% unique()
)

links$IDsource <- match(links$source, nodes$name)-1 
links$IDtarget <- match(links$target, nodes$name)-1

p <- sankeyNetwork(Links = links, Nodes = nodes,
                   Source = "IDsource", Target = "IDtarget",
                   Value = "aggamt", NodeID = "name", 
                   sinksRight=FALSE)
p

I able to plot the Senkey diagram enter image description here

While i would like to consider date in the consideration, how i plot chart like below?

enter image description here

Expected output: the chart with date in the consideration.

enter image description here

Yin LI
  • 1

0 Answers0