I'm trying to create a Sankey Diagram for the following dataset (only categorical variables), but I'm not having luck setting up the sankeyNetwork parameters (target, source, value).
Find below my code.
Could you please help me clarify what is wrong here?
node_names <- unique(c(as.character(sk_dataset$Race), as.character(sk_dataset$Gender)))
nodes <- data.frame(name=node_names)
links <- data.frame(source=match(sk_dataset$Gender, node_names) -1,
target = match(sk_dataset$Race, node_names) -1,
value=c(2,3, 2, 3, 1, 3))
sankeyNetwork(Links=links, Nodes=nodes,Source="source",
Target="target", Value="value")
Example of what I want to achieve: Example