Have
sigmajs
play hand-in-hand with other
htmlwidgets,
such as
leaflet,
or
DT
to highlight nodes and neighbours on click.
Install the stable version from CRAN.
install.packages("sigmajs")
or the development version Github or Bitbucket.
# install.packages("remotes")
remotes::install_github("JohnCoene/sigmajs") # github
remotes::install_bitbucket("JohnCoene/sigmajs") # bitbucket
Note that the graphs do not work in the RStudio viewer, and thus open in your default browser.
library(sigmajs)
# generate data
nodes <- sg_make_nodes(25) # 20 nodes
edges <- sg_make_edges(nodes, 50) # 50 edges
sigmajs() %>% # initialise
sg_nodes(nodes, id, label, size) %>% # add nodes
sg_edges(edges, id, source, target) %>% # add edges
sg_layout() %>% # layout
sg_cluster() %>% # cluster
sg_drag_nodes() %>% # allows user to drag nodes
sg_neighbours() # show node neighbours on node click