Friday, January 23, 2015
Visualizing Internet … InteractivityI found a new R package called networkD3 that gives interactivity to network graphs using D3.js.
We need to manipulate the data because the
forceNetworkfunction only allow a list of numbered edges starting in 0. We are going to use a simple trick, using the
write.graphfunction from igraph and the edgelist format it writes the links in this way, so we only need to read the file again to a new variable.
Let’s look the graphs from Singapur and Ukraine this way
library(igraph) write.graph(bsk,file ="countrySG.edges", format = "edgelist") Links<-read.table("countrySG.edges")
library(networkD3) forceNetwork(Links = Links, Nodes = MisNodes, Source = "V1", Target = "V2", NodeID = "name", Group = "group", opacity = 0.4)
Cool graphs with only a few lines of code.
forceNetwork(Links = Links, Nodes = MisNodes, Source = "V1", Target = "V2", NodeID = "name", Group = "group", opacity = 0.4)