Introduction
visNetwork is an R package for network visualization, using vis.js javascript library (http://visjs.org/). All remarks and bugs are welcome on github : https://github.com/datastorm-open/visNetwork.
Features
Based on htmlwidgets, so :
- compatible with shiny, R Markdown documents, and RStudio viewer
The package proposes all the features available in vis.js API, and even more with special features for R :
- easy to use
- custom shapes, styles, colors, sizes, …
- works smooth on any modern browser for up to a few thousand nodes and edges
- interactivity controls (highlight, collapsed nodes, selection, zoom, physics, movement of nodes, tooltip, events, …)
- visualize
rpart
tree
Installation
Package is now available on CRAN.
install.packages("visNetwork")
# can have new features in development version
devtools::install_github("datastorm-open/visNetwork")
How does it work ?
visNetwork needs at least two pieces of information :
- a nodes data.frame, with
id
column - an edges data.frame, with
from
andto
columns, which make the link withid
require(visNetwork, quietly = TRUE)
# minimal example
nodes <- data.frame(id = 1:3)
edges <- data.frame(from = c(1,2), to = c(1,3))
visNetwork(nodes, edges, width = "100%")
Need help ?
Besides the help R functions, a vignette is available, and you can access and read the full javascript API from R using visDocumentation():
# javascrtip api
visDocumentation()
vignette("Introduction-to-visNetwork") # with CRAN version
# shiny example
shiny::runApp(system.file("shiny", package = "visNetwork"))