set.seed(123)
nodes <- data.frame(id = 1:10, color = c(rep("blue", 6), rep("red", 3), rep("green", 1)))
edges <- data.frame(from = round(runif(6)*10), to = round(runif(6)*10))
visNetwork(nodes, edges, legend = TRUE) %>%
visClusteringByConnection(nodes = 9)
visNetwork(nodes, edges, legend = TRUE) %>%
visClusteringByConnection(nodes = c(9,5))
Run the code above in your browser using DataLab