• Stars
    star
    638
  • Rank 67,664 (Top 2 %)
  • Language
    R
  • Created over 9 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

D3 JavaScript Network Graphs from R

D3 JavaScript Network Graphs from R

Development version: 0.4.9000 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.

Usage

Here's an example of simpleNetwork:

library(networkD3)

# 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
simpleNetwork(networkData)

Here's forceNetwork:

# Load data
data(MisLinks)
data(MisNodes)

# Plot
forceNetwork(Links = MisLinks, Nodes = MisNodes, Source = "source",
             Target = "target", Value = "value", NodeID = "name",
             Group = "group", opacity = 0.7,
             colourScale = JS("d3.scaleOrdinal(d3.schemeCategory20);"))

Here's sankeyNetwork using a downloaded JSON data file:

# Recreate Bostock Sankey diagram: http://bost.ocks.org/mike/sankey/
# Load energy projection data
URL <- paste0("https://cdn.rawgit.com/christophergandrud/networkD3/",
              "master/JSONdata/energy.json")
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)

Interacting with igraph

You can use igraph to create network graph data that can be plotted with networkD3. The igraph_to_networkD3 function converts igraph graphs to lists that work well with networkD3. For example:

# Load igraph
library(igraph)

# Use igraph to make the graph and find membership
karate <- make_graph("Zachary")
wc <- cluster_walktrap(karate)
members <- membership(wc)

# Convert to object suitable for networkD3
karate_d3 <- igraph_to_networkD3(karate, group = members)

# Create force directed network plot
forceNetwork(Links = karate_d3$links, Nodes = karate_d3$nodes, 
             Source = 'source', Target = 'target', NodeID = 'name', 
             Group = 'group')

Saving to an external file

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

library(magrittr)

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

Note

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

More Repositories

1

Rep-Res-Book

Source code files for the book Reproducible Research with R/RStudio
TeX
199
star
2

d3Network

Tools for creating D3 JavaScript network graphs from R.
R
170
star
3

dpmr

Data Package Manager for R
R
55
star
4

DataCombine

R tools for combining data sets.
R
52
star
5

Introduction_to_Statistics_and_Data_Analysis_Yonsei

Introduction to Applied Data Analysis for Social Science
TeX
49
star
6

imfr

R package for interacting with the IMF RESTful JSON API
R
38
star
7

repmis

Miscellaneous tools for reproducible research with R.
R
24
star
8

EIUCrisesMeasure

Real-time perceptions of financial market stress measured using kernel PCA
TeX
17
star
9

networkD3-shiny-example

An example of a Shiny web app using networkD3 graphs
R
16
star
10

Rep-Res-Examples

Examples
R
15
star
11

d3ShinyExample

An example of how to use the R package d3Network with RStudio's Shiny web apps
R
15
star
12

simPH

Tools for simulating and graphing results from proportional hazards survival models.
R
14
star
13

LSE-Beamer-Theme

An Unofficial LSE LaTeX Beamer Theme
12
star
14

Rep-Res-ExampleProject1

An full example reproducible research project for "Reproducible Research with R and RStudio"
R
12
star
15

ExpAgenda

A bayesian hierarchical topic model for texts in R. The package implements Grimmer (2010).
R
12
star
16

Disproportionality_Data

A .csv file of Gallagher Disproportionality Data
R
8
star
17

Make-Projects

Shell scripts to create basic files and directories for books and other long documents.
TeX
7
star
18

oecdr

Download and format data from the OECD
R
7
star
19

plotMElm

An R package to plot marginal effects for interactions estimated from linear models
R
6
star
20

language-knitr

atom.io support for knitr
6
star
21

mcreplicate

Multi-core replicate for RStats
R
5
star
22

Country-Name-Standardizer

Standardizes country names in data sets.
5
star
23

coreSim

Core Functionality for Simulating Quantities of Interest from Generalised Linear Models
R
5
star
24

spatialWeights

Calculate spatial weights for time-series cross-sectional data and report spatial clustering test statistics
R
4
star
25

GreenBook

Research on Federal Reserve Green Book inflation forecast errors.
TeX
4
star
26

rep-res-book-v3-examples

Complete examples from Reproducible Research with R and RStudio [Third Edition]
HTML
4
star
27

misc-speaking-notes

Repository for sharing speaking notes from various talk I've given
3
star
28

FedSpeech

Source code/data files for "What the Fed Says" Project (Kevin Young & Christopher Gandrud)
HTML
3
star
29

di-governance

Data and additional material for Competing Risks and Deposit Insurance Governance Convergence
Ruby
3
star
30

datafest2017_rep_research_tools

Harvard DataFest 2017--Tools for Reproducible and Collaborative Data Science
HTML
3
star
31

cv

Personal CV
TeX
2
star
32

eurostat_revisions

A project exploring the political causes of revisions to Eurostat debt statistics
TeX
2
star
33

PoliSciGitData

A short article describing how to use GitHub to store and collaborate on political science data.
2
star
34

tlsl_monte_carlo_experiments

Monte Carlo experiments on time-lagged spatial lagged regressions
R
2
star
35

simGLM

Simulate and Plot Quantities of Interest from Generalised Linear Models
R
2
star
36

ela_fiscal_costs

An exploration on the relationships between Emergency Liquidity Assistance and the fiscal costs of financial crises
TeX
2
star
37

simPHDoc

Documentation for the simPH R package.
Shell
2
star
38

predicting_finstress

Understanding variance in financial market stress
R
2
star
39

intro-data-retrieval-management

Materials for RTG Humboldt/Hertie Programming Methods for Data
JavaScript
2
star
40

LegislativeViolence

Repository for Research on Legislative Violence
TeX
2
star
41

InterpretingHazRatios

Project on interpreting hazard ratios in policy diffusion research.
TeX
2
star
42

CarouselMapsHowTo

A slideshow explaining how to use the Twitter Bootstrap plug-in Carousel to show timeline maps.
JavaScript
2
star
43

RepResR-RStudio

The website for the book "Reproducible Research with R and RStudio"
JavaScript
2
star
44

christophergandrud.github.com

CSS
2
star
45

drlearner

Doubly Robust Machine Learner with sample splitting for Heterogeneous Treatment Effect Estimation and Approximately Optimal Treatments using Best Linear Projections
R
1
star
46

MannheimPresentation2014

Presentation for Computational linguistics in political science at the University of Mannheim 2014
TeX
1
star
47

IndvBankDataAnalysis

Source and description files for individual bank data analysis
R
1
star
48

jena-statistical-workflow

Materials for Workflow of Statistical Data Analysis [Jena July 2021]
HTML
1
star
49

Alt_et_al_2014_Replication

A replication of Alt et al. (2014) using corrected election timing data
Stata
1
star
50

StanCat

Creates caterpillar plots from stanfit objects
R
1
star
51

dynsim

An R implementation of dynamic simulations of autoregressive relationships
R
1
star
52

zibHelpers

Helper functions for handling results from Bayesian Zero-inflated Beta Regressions in R
R
1
star
53

Keefer2007Replication

A replication of Keefer (2007) using updated data on the fiscal costs of financial crises
R
1
star
54

psDataCSVConf

Talk on psData for csvConf 2014
1
star
55

eu_members

A List of European Union Members and their country-years of membership
R
1
star
56

CoxHRDist

Research note on showing hazard rate distributions estimated from Cox PH models.
1
star
57

pltesim

Simulate probabilistic long-term effects in models with temporal dependence
R
1
star
58

yrcurnt_corrected

Corrects errors and inconsistencies in the Database of Political Institution's years to election (yrcurnt) variable
R
1
star
59

BankingUnionMaps

Maps of European Banking Union
R
1
star
60

GuaranteeGame

A simple Python based simulation of banking crisis containment policymaking.
R
1
star
61

WayOut

A proposal for numbering subway exits in Western countries
CSS
1
star
62

simpleSetup

Simple Functions for Setting Up An R Source Code File For Use on Multiple Machines
R
1
star
63

stats_batch

Python package for finding statistics (e.g. mean and variance) using batch updating
Python
1
star
64

FOMCForecasts

An examination of FOMC members' forecasts presented during Congressional testimony.
TeX
1
star
65

bisMembers

A simple data set of Bank of International Settlements members.
R
1
star
66

CrisisDataIssues

Reassessing data used in the study of political institutions and financial crises
R
1
star
67

JurisdictionYear

R code to create a data frame of valid jurisdiction-year observations
R
1
star
68

fredr

Download a variable from FRED (https://research.stlouisfed.org/fred2/) for multiple countries
R
1
star
69

AMCMisc

Miscellaneous files related to the AMC project.
R
1
star
70

eu_ms_statistical_agency_tenure

Exploration of the tenure of EU member states' statistical agency heads
R
1
star
71

Tier1StyleGuide

Style Guide for Tier 1 Exchange
CSS
1
star
72

simtvc

Tools for simulating and graphing time-varying coefficients.
R
1
star
73

FinRegGov

Data set of financial regulatory governance institutions.
R
1
star
74

LoadandCiteNote

A short note on how to use the LoadandCite command for documenting R packages used in reproducible research.
1
star
75

financial_crisis_fiscal_policy

Research examining how elections affect fiscal policy responses to financial crises
R
1
star
76

datafest2017_dashboard_shiny

Harvard DataFest 2017--Intro to dynamic web documents with dashboards and Shiny
HTML
1
star
77

IFTIndex

International Fiscal Transparency Index
R
1
star
78

BasicBayesianPresent

A short presentation created for the Inaugural Meeting of the (Hertie) Bayesian Statistics Study Group
1
star