I have this code:
library(networkD3)
# Load data
data(MisLinks)
data(MisNodes)
new.nodes <- MisNodes
new.nodes$var1 <- runif(nrow(MisNodes),1,2)
new.nodes$var2 <- runif(nrow(MisNodes),1,2)
# Some script to show the node index in the new.nodes data frame
script <- 'alert("row: " + (d.index + 1));'
# Plot
forceNetwork(Links = MisLinks, Nodes = new.nodes,
Source = "source", Target = "target",
Value = "value", NodeID = "name",
Group = "group", opacity = 0.8,
clickAction = script)
I figured out to get the row number of the node data frame by asking for d.index + 1
. However I want to show a table containing all the node info, like so (perhaps nicer formatted):
name group size var1 var2
1 Myriel 1 15 1.501311 1.053062
This would require the JavaScript to have access to the node data frame, as I only have little knowledge of JavaScript I cannot figure out how to request this data.