3 Example Application 2

library(networkD3)
## 
## Attaching package: 'networkD3'
## The following object is masked from 'package:leaflet':
## 
##     JS
# Create data

src <- c(rep("sp1",5),rep( "sp2",5),rep( "sp1",5),rep("sp4",5))
trg <- c(rep("sp10",3),rep( "sp1",3),rep( "sp7",4),rep("sp8",3),rep("sp9",5),
         rep("sp10",2))
value <-c(sample(1:100,60))

network <- data.frame("source"= src, "target"= trg, "value" = value)

simpleNetwork(network)

Figure 3.1: An example of a simple network

# Force directed graphs

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

Figure 3.2: An example of a force directed network