Saving networkD3 Sankey diagram using code only
问题 I've created a Sankey diagram in R, using the networkD3 package, that I'd like to save as a static image, using code instead of clicking on 'Export' --> 'Save as Image...'. The current code I've tried (using this Sankey diagram as an example) is: library(networkD3) URL <- paste0( "https://cdn.rawgit.com/christophergandrud/networkD3/", "master/JSONdata/energy.json") Energy <- jsonlite::fromJSON(URL) # Plot jpeg( filename = "Sankey.jpg", width = 4000, height = 4000) sankeyNetwork(Links = Energy