Define groups of nodes
You can affect a group to a node using the group
column in the node data.frame, and then add a configuration per group using the visGroups function. And therefore, you can transfer less data to javascript
…
nodes <- data.frame(id = 1:5, group = c(rep("A", 2), rep("B", 3)))
edges <- data.frame(from = c(2,5,3,3), to = c(1,2,4,2))
visNetwork(nodes, edges, width = "100%") %>%
# darkblue square with shadow for group "A"
visGroups(groupname = "A", color = "darkblue", shape = "square",
shadow = list(enabled = TRUE)) %>%
# red triangle for group "B"
visGroups(groupname = "B", color = "red", shape = "triangle")