Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sankeyNetwork in blank in R 4.4.0 #302

Open
Pablo-Sar opened this issue May 24, 2024 · 3 comments
Open

sankeyNetwork in blank in R 4.4.0 #302

Pablo-Sar opened this issue May 24, 2024 · 3 comments

Comments

@Pablo-Sar
Copy link

I followed the example in https://r-charts.com/flow/sankey-diagram-ggplot2/ to plot the sankey diagram but in the viewer just appeared in blank without any error in the console.
Captura de pantalla (1589)

@Pablo-Sar
Copy link
Author

I pasted the screenshot in R 4.3.3 since I change the version to plot the diagram.

In R 4.3.3 works just fine.

@cjyetman
Copy link
Collaborator

can you copy-paste the reproducible code here?

@Pablo-Sar
Copy link
Author

Pablo-Sar commented May 25, 2024

can you copy-paste the reproducible code here?

Sorry I put another example in my description.

Load package
library(networkD3)

Load energy projection data
URL <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json"
Energy <- jsonlite::fromJSON(URL)

Now we have 2 data frames: a 'links' data frame with 3 columns (from, to, value), and a 'nodes' data frame that gives the name of each node.
head( Energy$links )
head( Energy$nodes )

Thus we can plot it
sankeyNetwork(Links = Energy$links,
Nodes = Energy$nodes,
Source = "source",
Target = "target",
Value = "value",
NodeID = "name",
units = "TWh",
fontSize = 12,
nodeWidth = 30)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants