D3 JavaScript Network Graphs from R

Version 0.2.10 CRAN Version Build Status CRAN Monthly Downloads CRAN Total Downloads

This README includes information on set up and a number of basic examples. For more information see the package's main page.


Here's an example of simpleNetwork:

# Create fake data
src <- c("A", "A", "A", "A", "B", "B", "C", "C", "D")
target <- c("B", "C", "D", "J", "E", "F", "G", "H", "I")
networkData <- data.frame(src, target)

# Plot

Here's forceNetwork:

# Load data

# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 0.4,
             colourScale = "d3.scale.category20b()")

Here's sankeyNetwork using a downloaded JSON data file:

# Recreate Bostock Sankey diagram:
# Load energy projection data
URL <- paste0("",
Energy <- jsonlite::fromJSON(URL)

# Plot
sankeyNetwork(Links = Energy$links, Nodes = Energy$nodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             units = "TWh", fontSize = 12, nodeWidth = 30)

Saving to an external file

Use saveNetwork to save a network to stand alone HTML file:


simpleNetwork(networkData) %>% saveNetwork(file = 'Net1.html')


networkD3 began as a port of d3Network package to the htmlwidgets framework. d3Network is no longer supported.

jrdnmdhl/networkD3 documentation built on May 18, 2017, 9:31 p.m.