Lambo
Lambo

Reputation: 897

How to visualize the graph using d3Network in R

I'm trying to use a package called d3Network in R to visualize some network and I used the example in R :

# Load data
data(MisLinks)
data(MisNodes)

# Create graph
d3ForceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
               Target = "target", Value = "value", NodeID = "name",
               Group = "group", opacity = 0.4)

It only gives me a bunch of scripts rather than a plot. I saw this example on the internet and it seems the others have never come cross this kind of issue. So am I doing something wrong or something is missing? And also I would like to know how to specify the colour of Source nodes and Target nodes.

Thanks in advance

Upvotes: 3

Views: 870

Answers (1)

Suraj
Suraj

Reputation: 487

It seems you are using d3Network package which is old and not supported anymore. Try using networkD3 package.
The function name is: forceNetwork

Try this:

library(networkD3)
data(MisLinks)
data(MisNodes)
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 1)

Upvotes: 6

Related Questions