networkd3

Put line break in node labels in networkD3 sankey diagram

瘦欲@ 提交于 2019-12-21 07:47:08
问题 ++++++++++++++++ Update: I think the answer to my question is that you can't put line breaks in. A colleague pointed out to me the node labels are SVG blocks, which don't support line breaks. ++++++++++++++++ How do I put a line break into the node labels for a sankey diagram produced using the networkD3 R package? Borrowing the example from Place text values to right of sankey diagram I can add values to the lables: library(networkD3) library(data.table) set.seed(1999) links <- data.table(

forceNetwork not displaying, no code errors returned

ε祈祈猫儿з 提交于 2019-12-19 21:49:49
问题 I am creating a networkD3 forceNetwork(), but after I cleared my env vars in RStudio the network would not display in my browser when I ran the code a second time. Any idea why? No code errors. Var output is below. library(networkD3) library(igraph) setwd("C:\\Users\\King\\Desktop\\SNA_Rcode") csv<-read.csv("C:\\Users\\King\\Desktop\\Analysis\\mc_with_0_and_MI.csv") df<-data.frame(csv$stat.deaths,csv[,4],csv$stat.mob)#damage delt on deaths, mob kills (is color) #2 mode. interactive model #g1

Fixing the order of a Sankey flow graph in R / networkD3 package

家住魔仙堡 提交于 2019-12-19 09:32:10
问题 I would like to visualize a rank change (i.e. change of the relative order) of US states using a Sankey flow graph. I'm using the networkd3 package and came up with the following: library(dplyr) library(networkD3) df <- data_frame(origins=state.name[1:10], destinations=state.name[1:10]) lab <- c(df$origins, df$destinations) nodes <- data.frame(node=c(0:9), name=lab) links <- data.frame(source=c(0:9), target=c(10:19), value=rep(1,10)) sankeyNetwork(Links = links, Nodes = nodes, Source =

Fixing the order of a Sankey flow graph in R / networkD3 package

你离开我真会死。 提交于 2019-12-19 09:30:15
问题 I would like to visualize a rank change (i.e. change of the relative order) of US states using a Sankey flow graph. I'm using the networkd3 package and came up with the following: library(dplyr) library(networkD3) df <- data_frame(origins=state.name[1:10], destinations=state.name[1:10]) lab <- c(df$origins, df$destinations) nodes <- data.frame(node=c(0:9), name=lab) links <- data.frame(source=c(0:9), target=c(10:19), value=rep(1,10)) sankeyNetwork(Links = links, Nodes = nodes, Source =

How to color groups in networkD3's sankeyNetwork?

[亡魂溺海] 提交于 2019-12-19 03:56:39
问题 My nodes consists of names and groups yet I can't seem to implement distinct colors for groups in my sankey diagram. The colors are either all blue with defaults or all black using the code below. Here's the code I use: sankeyNetwork( Links = data$links, Nodes = data$nodes, Source= "source", Target = "target", Value = "weight", NodeID = "names", fontSize = 15, NodeGroup = "group" )) Here's the output I'm getting: 回答1: The NodeGroup vector in the Nodes data frame needs to be non-numeric. That

Sankey diagram in R

痴心易碎 提交于 2019-12-18 13:28:21
问题 Attempting to make a fairly generic Sankey diagram with the help of R's networkD3 package. Just for reference--here's the example from the package's manual library(networkD3) library(jsonlite) library(magrittr) energy <- "https://cdn.rawgit.com/christophergandrud/networkD3/master/JSONdata/energy.json" %>% fromJSON sankeyNetwork(Links = energy$links, Nodes = energy$nodes, Source = "source", Target = "target", Value = "value", NodeID = "name", units = "TWh", fontSize = 12, nodeWidth = 30) which

Place text values to right of sankey diagram

微笑、不失礼 提交于 2019-12-18 05:53:31
问题 Is there a trick to placing text on a sankey diagram rendered using networkD3? I would like to have the values of the endpoints be displayed as text to the right of their boxes. I realize that hovering over the boxes displays the value, but as the boxes get smaller it would be much easier in many cases to portray the information if the values were always visible on the side. Here is an example; I was able to kinda hack it by adding the values as part of the labels, but it would be much better

R networkD3 package: node coloring in simpleNetwork()

僤鯓⒐⒋嵵緔 提交于 2019-12-17 10:55:15
问题 The networkD3 package (see here and here) allows a user to create simple interactive networks: # Load package library(networkD3) # Create fake data src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D") target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I") networkData <- data.frame(src, target) # Plot simpleNetwork(networkData) Is there a way to specify that I want all elements in the src vector to be a certain color, while allowing all the elements in the target vector to be a different

forceNetwork not displaying any edges

那年仲夏 提交于 2019-12-14 03:59:07
问题 I am trying to figure out the EXACT requirements for the node and link dataframes in forceNetwork() because my network is displaying colored movable points without any edges connecting them and I dont know why. As far as I can tell the requirements are: nodes dataframe must have: a nodeID column (if nodes arent in the same order as the links) that exactly matches the link source name. If they are in the same order this parameter can be dropped according to my reading of the documentation. a

How to capture html output as png in R

删除回忆录丶 提交于 2019-12-12 18:34:28
问题 I use interactive output created by networkD3 package in R. I know how to save the output as html page, but I also need to save the 'static' version of the diagram as .png file. The code looks like this: # Load package library(networkD3) # Create fake data src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D") target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I") networkData <- data.frame(src, target) # Plot simpleNetwork(networkData) I can save the output by clicking on 'Export' and then