networkd3

Saving networkD3 Sankey diagram using code only

无人久伴 提交于 2021-02-20 13:34:34
问题 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

Saving networkD3 Sankey diagram using code only

折月煮酒 提交于 2021-02-20 13:33:09
问题 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

Saving networkD3 Sankey diagram using code only

蹲街弑〆低调 提交于 2021-02-20 13:32:07
问题 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

structuring binary data for sankey plot

橙三吉。 提交于 2021-02-08 07:50:41
问题 I am having trouble figuring out how to make a sankey plot for data where there are multiple opportunities of success (1) or failure (0). You can generate my sample with the following code: # example library(networkD3) library(tidyverse) library(tidyr) set.seed(900) n=1000 example.data<-data.frame("A" = rep(1,n), "B" = sample(c(0,1),n,replace = T), "C" = rep(NA,n), "D" = rep(NA,n), "E" = rep(NA,n), "F" = rep(NA,n), "G" = rep(NA,n)) for (i in 1:n){ example.data$C[i]<- ifelse(example.data$B[i]=

structuring binary data for sankey plot

霸气de小男生 提交于 2021-02-08 07:50:21
问题 I am having trouble figuring out how to make a sankey plot for data where there are multiple opportunities of success (1) or failure (0). You can generate my sample with the following code: # example library(networkD3) library(tidyverse) library(tidyr) set.seed(900) n=1000 example.data<-data.frame("A" = rep(1,n), "B" = sample(c(0,1),n,replace = T), "C" = rep(NA,n), "D" = rep(NA,n), "E" = rep(NA,n), "F" = rep(NA,n), "G" = rep(NA,n)) for (i in 1:n){ example.data$C[i]<- ifelse(example.data$B[i]=

NetworkD3 Sankey Plot in R: How to switch text labels from the right to the left of the inner nodes only

坚强是说给别人听的谎言 提交于 2021-02-08 06:52:38
问题 I created a Sankey Plot using the NetworkD3 R package. Below is an example of the output: Sankey Plot Example I used the following code for the Sankey: sankeyNetwork(Links = SankeyLinks, Nodes = SankeyNodes, Source = "source", Target = "target", Value = "value", NodeID = "names", fontSize = 14, nodeWidth = 20,nodePadding = 15,NodeGroup = "nodeColor", colourScale = JS(ColourScale), LinkGroup = "linkColor", sinksRight = T) The network generates text labels to the right of the middle nodes,

NetworkD3 Sankey Plot in R: How to switch text labels from the right to the left of the inner nodes only

拜拜、爱过 提交于 2021-02-08 06:52:12
问题 I created a Sankey Plot using the NetworkD3 R package. Below is an example of the output: Sankey Plot Example I used the following code for the Sankey: sankeyNetwork(Links = SankeyLinks, Nodes = SankeyNodes, Source = "source", Target = "target", Value = "value", NodeID = "names", fontSize = 14, nodeWidth = 20,nodePadding = 15,NodeGroup = "nodeColor", colourScale = JS(ColourScale), LinkGroup = "linkColor", sinksRight = T) The network generates text labels to the right of the middle nodes,

enable horizontal movement of nodes in networkD3's sankeyNetwork plots

∥☆過路亽.° 提交于 2021-01-29 10:44:16
问题 I found this image from the Internet (link) and I think it was draw in R. I tried to reproduce this Figure and make it more or less similar with one from the above link. The code I used is as following: ID <- 0:24 NodeGroup <- c(rep(1,8),2,5,rep(4,7),3,5,6,6,7,7,8,9) name <- c("29581k","5279k","4218k","1917k","1356k","Ventas diversas: 116","Venta diversa: 97","Venta de: 141","Venta totales: 42705","Contribucion marginal: 18183", "17531k","1744k","1326k","1208k","526k","459k","14k","IIBB: 1714

Unable to vary linkDistance in network graph created using forceNetwork of networkD3

邮差的信 提交于 2020-06-17 04:07:20
问题 I am trying to create a force directed network graph in R using the networkD3 package. Everything works well ... devtools::install_github('christophergandrud/networkD3') library(networkD3) links2 <- data.frame( Source = c(0, 0, 0, 1, 2, 3), Target = c(1, 4, 5, 3, 4, 5), Value = c(1, 9.9, 10, 8.8, 6.6, 7.2)) nodes2 <- data.frame(ID = 0:5, Group = c(1L, 1L, 1L, 2L, 1L, 2L)) # this works forceNetwork(Links=links2, Nodes=nodes2, Source="Source", Target="Target", Value="Value", NodeID="ID", Group=

How to subset data in networkD3 on Shiny?

五迷三道 提交于 2020-05-29 09:36:07
问题 Here is a reproducible example: library(networkD3) MyNodes<-data.frame(name= c("A", "B", "C", "D", "E", "F"), size= c("1","1","1","1","1","1"), Team= c("Team1", "Team1", "Team1", "Team1", "Team2", "Team2"), group= c("Group1", "Group1", "Group2", "Group2", "Group1", "Group1")) MyLinks<-data.frame(source= c("0","2","4"), target= c("1","3","5"), value= c("10","50","20")) forceNetwork(Links = MyLinks, Nodes = MyNodes, Source = "source", Target = "target", Value = "value", NodeID = "name",