networkd3

forceNetwork not displaying, no code errors returned

流过昼夜 提交于 2019-12-01 19:42:10
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 <- simpleNetwork(df) ; htmltools::html_print(g1, viewer = utils::browseURL)#DISPLAYS CORRECTLY df <- df

Colouring scheme in networkD3 vs igraph

瘦欲@ 提交于 2019-12-01 12:08:44
I have a network where I have characterised each of the nodes with previous analysis- and have assigned the colours as follows: plot.igraph(g, layout=layout.fruchterman.reingold(g), vertex.color=node_colors, vertex.label = node_names) The variable 'node_colors' is a vector that was made from previous analysis so that the colours would coincide with the vertex placement/ clustering. However when I try to implement a personalised colouring scheme in networkD3, I get an 'unused argument' error: data<-igraph_to_networkD3(g, group = members) forceNetwork(Links = data$links, Nodes = data$nodes,

R networkD3 color node stroke for radialNetwork()

二次信任 提交于 2019-12-01 10:59:37
The networkd3 package contains some very nice functions for creating the obvious networks. Different functions have different arguments, so this questions is specifically in regards to the radialNetwork() function. Is it possible to have the color of the node stroke change according to a given vector? The below code creates a the network graph but changing the argument for the node stroke to a vector containing different colors does not work. library(networkD3) library(tidyverse) library(data.tree) ## Data input <- list(number=50) Data_tree <- data.frame(Start="Class", Asset = sample(c("FI",

Colouring scheme in networkD3 vs igraph

随声附和 提交于 2019-12-01 10:13:22
问题 I have a network where I have characterised each of the nodes with previous analysis- and have assigned the colours as follows: plot.igraph(g, layout=layout.fruchterman.reingold(g), vertex.color=node_colors, vertex.label = node_names) The variable 'node_colors' is a vector that was made from previous analysis so that the colours would coincide with the vertex placement/ clustering. However when I try to implement a personalised colouring scheme in networkD3, I get an 'unused argument' error:

Search box in network Plot

末鹿安然 提交于 2019-11-30 23:32:12
I have created a Network of protein mutations using the forceNetwork() function of the networkD3 package. It get's rendered on the RStudio's "Viewer" pane. I can then save this as an HTML file, for sharing, with the dynamic nature (like clicking nodes, highlighting connections etc) preserved. A png version of my network plot looks like below: This is a representation of a top 20% in my original data, and the complete data looks even more huge and complex. I need to be able to add a search to this forceNetwork, so that then specific nodes can be located in a complex network. The javascript or

Transform a dataframe into a tree structure list of lists

泄露秘密 提交于 2019-11-30 20:08:13
I have a data.frame with two columns representing a hierarchical tree, with parents and nodes. I want to transform its structure in a way that I can use as an input for the function d3tree , from d3Network package. Here's my data frame: df <- data.frame(c("Canada","Canada","Quebec","Quebec","Ontario","Ontario"),c("Quebec","Ontario","Montreal","Quebec City","Toronto","Ottawa")) names(df) <- c("parent","child") And I want to transform it to this structure Canada_tree <- list(name = "Canada", children = list( list(name = "Quebec", children = list(list(name = "Montreal"),list(name = "Quebec City")

Search box in network Plot

自作多情 提交于 2019-11-30 18:12:56
问题 I have created a Network of protein mutations using the forceNetwork() function of the networkD3 package. It get's rendered on the RStudio's "Viewer" pane. I can then save this as an HTML file, for sharing, with the dynamic nature (like clicking nodes, highlighting connections etc) preserved. A png version of my network plot looks like below: This is a representation of a top 20% in my original data, and the complete data looks even more huge and complex. I need to be able to add a search to

linking a node in networkD3 to a website using clickAction = NULL

霸气de小男生 提交于 2019-11-30 17:04:20
Is there a way to use a node as a link to an external website using the function forceNetwork() in the networkD3 package in r ? I was thinking maybe modifying the clickAction ? Example data: library(networkD3) data(MisLinks) data(MisNodes) # Create a random URL in the nodes dataset MisNodes$URL <- paste0("http://www.RANDOMLINK_", sample(1:100, NROW(MisNodes)), ".com") head(MisNodes) MyClickScript <- 'alert(d.index)' forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source", Target = "target", Value = "value", NodeID = "name", Group = "group", opacity = 0.8, clickAction = MyClickScript

Sankey diagram in R

这一生的挚爱 提交于 2019-11-30 09:07:35
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 results in: My fairly straightforward extension consists of building a diagram with the following

Own colour range for Sankey Diagram with networkD3 package in R

爷,独闯天下 提交于 2019-11-30 05:39:27
问题 I am trying to plot Sankey diagrams using sankeyNetwork() in networkD3 package. sankeyNetwork(Links = Flow_data, Nodes = Nodes_data, Source = "Source_ID", Target = "Target", Value = "value", NodeID = "Nodes_name", width = 1000, height=600, fontsize = 16, nodeWidth = 50, colourScale = "d3.scale.category20c()") The visualization works great but I would like to change the colour range to an individual range. Is there any chance to change the colours of the SankeyNetwork? I need a range of only e