I have a file with export from source country to target country, the value of the trade is in Before_value dimension.
My data is in a data.table with dimensions source
and target
as character (list of country codes) and beofre_value
numeric.
I would like to generate a sankey diagram, using sankeyNetwork()
from networkd3, with the source countries on the left and the target countries on the right and the flows represented. How do I define the nodes and links data frames properly?
I have these lines:
library("networkD3")
sankeyNetwork(Links = IMP$source, Nodes = iMP$target, Source = "source",
Target = "target", Value = "Before_value", fontSize = 25,
nodeWidth = 30, fontFamily = "sans-serif", iterations = 0)
I got his error message: Error in Links[, Source] : incorrect number of dimensions