I am using the networkd3 package in r to produce sankey plots. I have used the following code to produce a working plot:
sankeyNetwork(Links = df_links, Nodes = df_nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
units = "Cases", fontSize = 12, nodeWidth = 20)
However, all the nodes are coloured blue, where I thought the default output of the package was to colour each node separately.
When I try to add a NodeGroup function, which the documentation says should allow colour to be displayed, all the node labels disappear and all the nodes are now coloured black.
sankeyNetwork(Links = df_links, Nodes = df_nodes, Source = "source",
Target = "target", Value = "value", NodeID = "name",
NodeGroup = "ID", units = "Cases", fontSize = 12,
nodeWidth = 20)
If anyone could let me know where I am going wrong that would be much appreciated. I suspect I am misunderstanding the usage of the NodeGroup
variable - I am currently assigning each of the seven NodeID
s a unique group c(0,1,2,3,4,5,6,7)
with the initial aim of having each node coloured differently. Is this the correct interpretation of the variable?