Created
March 5, 2018 13:45
-
-
Save jobonaf/f2002bb986dc4eb7fd29a8c10383f7f1 to your computer and use it in GitHub Desktop.
interactive network with R+d3.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(igraph) # Load the igraph package | |
links <- read.csv("data/network_crma_arpa_edges.csv") | |
net <- graph_from_data_frame(d=links, directed=T) | |
library(networkD3) | |
wc <- cluster_walktrap(net) | |
members <- membership(wc) | |
igraph_to_networkD3(net, group=members) -> net_d3 | |
net_d3$nodes$nodesize <- c(40,0)[(net_d3$nodes$name %in% links$from)+1] | |
forceNetwork(Links = net_d3$links, Nodes = net_d3$nodes, | |
Source = 'source', Target = 'target', NodeID = 'name', | |
Group = 'group', Nodesize = 'nodesize', | |
opacityNoHover = 1, fontSize = 10, | |
zoom=T, linkDistance = 70, | |
colourScale = JS("d3.scaleOrdinal(d3.schemeCategory10);")) -> nn | |
print(nn) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from | to | weight | |
---|---|---|---|
AIS_MA | Ferriera | 2 | |
DS_PRA | Ferriera | 1 | |
LAB | Ferriera | 1 | |
DS_RV | Ferriera | 1 | |
DS | Ferriera | 1 | |
STA_QAR | Ferriera | 1 | |
LAB | Inq.emergenti | 5 | |
STA_QAI | Inq.emergenti | 5 | |
AIS_MA | Inq.emergenti | 2 | |
GRE | Inq.emergenti | 1 | |
AGU | Inq.emergenti | 1 | |
DS_CRR | Inq.emergenti | 1 | |
STA_QAR | Monfalcone | 5 | |
LAB_AM | Monfalcone | 1 | |
LAB_MA | Monfalcone | 4 | |
DS | Monfalcone | 1 | |
AIS_MA | Monfalcone | 3 | |
STA_QAR | monitoraggio QA | 2 | |
AIS_MA | monitoraggio QA | 1 | |
AIS_MA | INEMAR | 1 | |
AIS_MA | simulazioni dispersione | 1 | |
AIS_MA | CALICANTUS | 1 | |
AIS_MA | PREPAIR | 1 | |
AIS_MA | COSMO | 1 | |
AIS_MA | ASI-ISPRA-QA | 1 | |
AIS_MA | forniture dati | 1 | |
STA_RF | catasto rifiuti | 3 | |
AIS_MA | catasto rifiuti | 1 | |
DS_PRA_VAL | PER | 6 | |
AIS_MA | PER | 1 | |
ArpaPiem | CALICANTUS | 1 | |
ARPAE | CALICANTUS | 1 | |
ArpaLazio | CALICANTUS | 1 | |
ArpaPiem | ASI-ISPRA-QA | 1 | |
ARPAE | ASI-ISPRA-QA | 1 | |
ArpaLazio | ASI-ISPRA-QA | 1 | |
ArpaPiem | COSMO | 1 | |
ARPAE | COSMO | 1 | |
ArpaPiem | PREPAIR | 1 | |
ARPAE | PREPAIR | 1 | |
AIS_MA | previsioni QA | 1 | |
AIS_MA | previsioni WRF | 1 | |
OSM | previsioni WRF | 1 | |
STA_QAR | previsioni QA | 5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment