I am creating a sankey diagram with the requirement of specific colors for 2nd level node and same color for 3 level node the data consists of 4 columns with heading EMER, PROV, DIS, COUNT
| EMER | PROV | DIST|COUNT|
| :— | :—:|:—:|—:|
| GL1 | ISS |RWW | 6 |
| GL1 | ISS |RSS | 9 |
| GL1 | ISS |PPL | 7 |
| GL1 | LLR |DID | 9 |
| GL1 | LLR |DOD | 5 |
| GL1 | PRP |RST | 9 |
I required to have a sankey diagram with EMER as 1st node and PROV as 2nd and DIST as 3rd and i wanted to keep the color of the 2nd node as red, green and blue. in addition my goal was to keep the color of 3rd node same as the color coming in it from the 2nd node but the 3rd node ends up in different colors. The code i used was:
library(networkD3)
library(plotly)
library(Rcpp)
library(digest)
library(jsonlite)
library(cpp11)
library(rmarkdown)
install_github("Displayr/flipPlots", dependencies = NA)
library(flipPlots)
SankeyDiagram(OD[, -4],
weights = OD$COUNT,
max.categories = 200,
link.color = "Source",
font.size = 12, # Change font.size
node.width = 15, # change Node.width
node.padding = 7, # Change node.padding
variables.share.values = TRUE,
label.show.varname = F;