I am trying to replicate the code and issue from below stack overflow question Sankey diagram in R
Adding some sample data
head(links) #Data.frame
Source Target Weight
Fb Google 20
Fb Fb 2
BBC Google 21
Microsoft BBC 16
head(nodes)
Fb
BBC
Google
Microsoft
Code for building a sankey transition flow
sankeyNetwork(Links = links,
Nodes = nodes,
Source = "Source",
Target = "Target",
Value = "value",
fontSize = 12,
nodeWidth = 30)
The above mentioned stack overflow posts mentions that the source and target should be indexed at 0. However if I try the same syntax, I get NA's in my Source and Target. What could be causing this error?
You can convert your Source and Target variables in your links data frame to the index of the nodes in your nodes data frame like so...